2023-06-11 12:14:03 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace FleetCart\Console\Commands;
|
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
|
|
use FleetCart\Scaffold\Module\Generators\EntityGenerator;
|
|
|
|
|
|
|
|
class ScaffoldEntityCommand extends Command
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The console command name.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $name = 'scaffold:entity';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'Scaffold a new entity with all its resources.';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The instance of EntityGenerator.
|
|
|
|
*
|
2023-12-03 14:07:47 +00:00
|
|
|
* @var EntityGenerator
|
2023-06-11 12:14:03 +00:00
|
|
|
*/
|
2023-12-03 14:07:47 +00:00
|
|
|
private EntityGenerator $entityGenerator;
|
|
|
|
|
2023-06-11 12:14:03 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new command instance.
|
|
|
|
*
|
2023-12-03 14:07:47 +00:00
|
|
|
* @param EntityGenerator $entityGenerator
|
2023-06-11 12:14:03 +00:00
|
|
|
*/
|
|
|
|
public function __construct(EntityGenerator $entityGenerator)
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
$this->entityGenerator = $entityGenerator;
|
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
2023-06-11 12:14:03 +00:00
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2023-12-03 14:07:47 +00:00
|
|
|
public function handle(): void
|
2023-06-11 12:14:03 +00:00
|
|
|
{
|
|
|
|
$this->entityGenerator
|
|
|
|
->module($this->argument('module'))
|
|
|
|
->generate([$this->argument('entity')], false);
|
|
|
|
|
|
|
|
$this->info('Entity generated.');
|
|
|
|
}
|
|
|
|
|
2023-12-03 14:07:47 +00:00
|
|
|
|
2023-06-11 12:14:03 +00:00
|
|
|
/**
|
|
|
|
* Get the console command arguments.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
2023-12-03 14:07:47 +00:00
|
|
|
protected function getArguments(): array
|
2023-06-11 12:14:03 +00:00
|
|
|
{
|
|
|
|
return [
|
|
|
|
['entity', InputArgument::REQUIRED, 'The name of the entity.'],
|
|
|
|
['module', InputArgument::REQUIRED, 'The name of module will be used.'],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|