| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?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
- {
- return parent::getOptions()[]=
- ['service', 'sv', InputOption::VALUE_NONE, 'Create a new service file'];
- }
- }
|