Last active
September 2, 2020 20:35
-
-
Save Frolki1-Dev/b00ef1b855f1d43322d0fff9ca0daae4 to your computer and use it in GitHub Desktop.
Revisions
-
Frolki1-Dev revised this gist
Sep 2, 2020 . 1 changed file with 10 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,6 +3,7 @@ namespace App\Console\Commands; use Illuminate\Console\Command; use Illuminate\Support\Facades\Storage; class CreateEntities extends Command { @@ -15,7 +16,8 @@ class CreateEntities extends Command {--m|minimal : Make only model and migration} {--np|no_policy : No policy file needed} {--nf|no_factory : No factory file needed} {--nr|no_resources : No resource files needed} {--s|seeder : Create a seeder file}'; /** * The console command description. @@ -45,9 +47,10 @@ public function handle() $model = sprintf('Models/%s', $class); $controller = sprintf('Api/v1/%sController', $class); $resource = sprintf('%s/%sResource', $class, $class); $collection = sprintf('%s/%sCollection', $class, $class); $policy = sprintf('%sPolicy', $class); $seeder = sprintf('%sSeeder', $class); // Run all command if (!$this->option('minimal')) { @@ -75,6 +78,10 @@ public function handle() $this->call('make:model', ['--migration' => 1, 'name' => $model]); } if($this->option('seeder')) { $this->call('make:seeder', ['name' => $seeder]); } return 0; } } -
Frolki1-Dev revised this gist
Sep 2, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -60,7 +60,7 @@ public function handle() $this->call('make:model', $model_arguments); if(!$this->option('no_policy')) { $this->call('make:policy', ['-m' => $model, 'name' => $policy]); } -
Frolki1-Dev created this gist
Sep 2, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,80 @@ <?php namespace App\Console\Commands; use Illuminate\Console\Command; class CreateEntities extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'tool:create_entity {name : The name of the class} {--m|minimal : Make only model and migration} {--np|no_policy : No policy file needed} {--nf|no_factory : No factory file needed} {--nr|no_resources : No resource files needed}'; /** * The console command description. * * @var string */ protected $description = 'Create a new model, migration, factory, policy, resource, collection and controller in one command.'; /** * Create a new command instance. * * @return void */ public function __construct() { parent::__construct(); } /** * Execute the console command. * * @return int */ public function handle() { $class = $this->argument('name'); $model = sprintf('Models/%s', $class); $controller = sprintf('Api/v1/%sController', $class); $resource = sprintf('%sResource', $class); $collection = sprintf('%sCollection', $class); $policy = sprintf('%sPolicy', $class); // Run all command if (!$this->option('minimal')) { $model_arguments = ['--factory' => 1, '--migration' => 1, 'name' => $model]; if($this->option('no_factory')) { unset($model_arguments['--factory']); } $this->call('make:model', $model_arguments); if(!$this->option('no_police')) { $this->call('make:policy', ['-m' => $model, 'name' => $policy]); } $this->call('make:controller', ['--api' => 1, 'name' => $controller]); if(!$this->option('no_resources')) { $this->call('make:resource', ['name' => $resource]); $this->call('make:resource', ['-c', 'name' => $collection]); } } else { // Only minimal (model and factory) $this->call('make:model', ['--migration' => 1, 'name' => $model]); } return 0; } }