The main question is in the title already.
I am using Laravel 5.4 right now, is there something like
php artisan make:model Category --migrations --controller
and can generate :
create_categories_table.php [migration]
Category.php [model]
CategoryController
To create a new migration, you can run the make:migration Artisan command and that will bootstrap a new class on your Laravel application, in the database/migrations folder.
Creating the Controller From the command line in the root directory of your Laravel project, type: php artisan make:controller sharkController --resource This will create our resource controller with all the methods we need.
You almost guessed the right answer. Yes, it is, you can make model + migration + controller, all in one line, using command:
php artisan make:model --migration --controller Test
Short version: php artisan make:model -m -c Test
Result:
Model created successfully.
Created Migration: 2017_02_27_153716_create_tests_table
Controller created successfully.
For additional syntax use -h
or --help
flag with command make:model
, it will show all available options for this command.
Also you can create not just an empty controller, but a resource controller with predefined CRUD methods. For that use additional flag -r
or --resource
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With