From 7dce0198f4fd9b01dd6cba93c7bdf2c3ec5a1710 Mon Sep 17 00:00:00 2001 From: Juzaweb Date: Sat, 5 Aug 2023 23:54:05 +0700 Subject: [PATCH] :+1: Make CRUD command --- .../Commands/Resource/CRUDMakeCommand.php | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/modules/DevTool/Commands/Resource/CRUDMakeCommand.php b/modules/DevTool/Commands/Resource/CRUDMakeCommand.php index da2d6f8f8..8eb367daa 100644 --- a/modules/DevTool/Commands/Resource/CRUDMakeCommand.php +++ b/modules/DevTool/Commands/Resource/CRUDMakeCommand.php @@ -13,6 +13,7 @@ use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Str; +use Juzaweb\CMS\Abstracts\Action; use Juzaweb\DevTool\Abstracts\CRUD\ResourceCommand; use Symfony\Component\Console\Input\InputArgument; @@ -61,11 +62,26 @@ public function handle(): void $this->info('Add resource route '.$routePath); - $content = "Route::jwResource('{$this->getTableNameNonePrefix($table)}', {$model}Controller::class);"; + $tableName = $this->getTableNameNonePrefix($table); + $content = "Route::jwResource('{$tableName}', {$model}Controller::class);"; - File::append($routePath, PHP_EOL . $content . PHP_EOL); + //File::append($routePath, PHP_EOL . $content . PHP_EOL); - $this->info("Add to your route: {$content}"); + $this->info("Generated CRUD for {$table} successfully."); + + $info = "Add to your route:\n\n"; + $info .= "use {$this->module->getNamespace()}Http\Controllers\Backend\{$model}Controller;\n"; + $info .= $content . "\n\n"; + + $info .= "And add to hook ". Action::BACKEND_INIT . " in your action:\n\n"; + $info .= "\$this->hookAction->registerAdminPage( + '{$tableName}', + [ + 'title' => '". Str::ucfirst($tableName) ."', + ] + );"; + + $this->comment($info); } protected function getTableColumns(string $table): array