Skip to content

Instantly share code, notes, and snippets.

@zgabievi
Last active January 14, 2018 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zgabievi/0d323ddf8c4f124cb81bca258745e293 to your computer and use it in GitHub Desktop.
Save zgabievi/0d323ddf8c4f124cb81bca258745e293 to your computer and use it in GitHub Desktop.
Artisan command make:scaffold to create all model related files in Laravel.
<?php
Artisan::command('make:scaffold {name?}', function ($name = null) {
$name = $name ?? $this->ask('What is the name of the model?');
$this->call('make:model', [
'name' => $name,
'--all' => true,
]);
if ($this->confirm('Do you want to create policy?')) {
$this->call('make:policy', [
'name' => $name . 'Policy',
'--model' => $name,
]);
}
if ($this->confirm('Do you want to create seeder?')) {
$this->call('make:seeder', [
'name' => str_plural($name) . 'TableSeeder',
]);
}
if ($this->confirm('Do you want to create unit test?')) {
$this->call('make:test', [
'name' => $name . 'Test',
'--unit' => true,
]);
}
$this->info("Scaffolding finished for {$name}.");
})->describe('Scaffold model and related files');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment