/home/techb158/immovalet.com/vendor/botble/widget-generator/src/Commands
Edit: /home/techb158/immovalet.com/vendor/botble/widget-generator/src/Commands/WidgetRemoveCommand.php (2538B)
files = $files;
$this->widgetRepository = $widgetRepository;
parent::__construct();
}
/**
* Execute the console command.
*
* @return boolean
*/
public function handle()
{
if (!$this->confirmToProceed('Are you sure you want to permanently delete?', true)) {
return 1;
}
$widget = $this->getWidget();
$path = $this->getPath();
if (!$this->files->isDirectory($path)) {
$this->error('Widget "' . $widget . '" is not existed.');
return 1;
}
try {
$this->files->deleteDirectory($path);
$this->widgetRepository->deleteBy([
'widget_id' => Str::studly($widget) . 'Widget',
'theme' => Theme::getThemeName(),
]);
$this->info('Widget "' . $widget . '" has been deleted.');
} catch (Exception $exception) {
$this->info($exception->getMessage());
}
return 0;
}
/**
* Get the theme name.
*
* @return string
*/
protected function getWidget(): string
{
return strtolower($this->argument('name'));
}
/**
* Get the destination view path.
*
* @return string
*/
protected function getPath(): string
{
return theme_path(Theme::getThemeName() . '/widgets/' . $this->getWidget());
}
}