| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace App\Console\Commands;
- use Illuminate\Support\Str;
- use Symfony\Component\Console\Input\InputOption;
- class MakeModelCommand extends \Illuminate\Foundation\Console\ModelMakeCommand
- {
- protected function getStub()
- {
- if ($this->option('pivot')) {
- return parent::getStub();
- }
- return __DIR__ . '/stubs/model.stub';
- }
- public function handle()
- {
- if (parent::handle() === false && ! $this->option('force')) {
- return false;
- }
- if ($this->option('all')) {
- $this->input->setOption('service', true);
- }
- if ($this->option('service')) {
- $this->createService();
- }
- }
- public function createService()
- {
- $modelName = Str::studly(class_basename($this->argument('name')));
- $this->call('make:service', [
- 'name' => "{$modelName}Service",
- ]);
- }
- protected function getOptions(): array
- {
- $options= parent::getOptions();
- $options[]=['service', 'sv', InputOption::VALUE_NONE, 'Create a new service file'];
- return $options;
- }
- }
|