Last active
February 10, 2021 16:06
-
-
Save codepotato/ee5a628719168bc9d2eb181f71e889f7 to your computer and use it in GitHub Desktop.
Make a model, API resource controller, resource, and two requests automagically in Laravel
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 characters
<?php | |
namespace App\Console\Commands; | |
use Illuminate\Console\Command; | |
use Illuminate\Support\Str; | |
class MakeAdminEntity extends Command | |
{ | |
/** | |
* The name and signature of the console command. | |
* | |
* @var string | |
*/ | |
protected $signature = 'make:api {model}'; | |
/** | |
* The console command description. | |
* | |
* @var string | |
*/ | |
protected $description = 'Make a model, API resource controller, migration, a "store" request and "update" request automagically'; | |
/** | |
* Create a new command instance. | |
* | |
* @return void | |
*/ | |
public function __construct() | |
{ | |
parent::__construct(); | |
} | |
/** | |
* Execute the console command. | |
* | |
* @return int | |
*/ | |
public function handle() | |
{ | |
$model = Str::ucfirst($this->argument('model')); | |
$this->call('make:model', [ | |
'name' => $model, '--resource' => true, '--controller' => true, '--migration' => true, | |
]); | |
$this->call('make:resource', [ | |
'name' => $model . 'Resource', | |
]); | |
$this->call('make:request', [ | |
'name' => 'Store' . $model, | |
]); | |
$this->call('make:request', [ | |
'name' => 'Update' . $model, | |
]); | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment