phases 8
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Developer\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Modules\Developer\Support\CrudGenerator;
|
||||
use Throwable;
|
||||
|
||||
final class MakeCrudCommand extends Command
|
||||
{
|
||||
protected $signature = 'crud:make {model} {--module=} {--force}';
|
||||
protected $description = 'Generate model, migration, request, controller, views and test inside a module.';
|
||||
|
||||
public function handle(CrudGenerator $generator): int
|
||||
{
|
||||
$module = $this->option('module') ?: $this->choice('Select the target module', $this->modules());
|
||||
try { $files = $generator->generate((string) $module, $this->argument('model'), (bool) $this->option('force')); }
|
||||
catch (Throwable $e) { $this->error($e->getMessage()); return self::FAILURE; }
|
||||
foreach ($files as $file) { $this->line("<info>created</info> {$file}"); }
|
||||
$this->warn('Register the generated controller routes in the target module Routes/web.php file.');
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
private function modules(): array
|
||||
{
|
||||
return collect(glob(base_path('Modules/*/module.json')) ?: [])->map(fn (string $file) => basename(dirname($file)))->sort()->values()->all();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user