Last active
January 14, 2018 18:33
-
-
Save zgabievi/0d323ddf8c4f124cb81bca258745e293 to your computer and use it in GitHub Desktop.
Artisan command make:scaffold to create all model related files in Laravel.
This file contains 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 | |
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