Skip to content

Commit

Permalink
👍 Make CRUD command
Browse files Browse the repository at this point in the history
  • Loading branch information
juzaweb committed Aug 5, 2023
1 parent 1407d7f commit 7dce019
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions modules/DevTool/Commands/Resource/CRUDMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7dce019

Please sign in to comment.