one two

Create Controller and Model in one Artisan Command

Laravel is full of little tricks, and quick ways to generate code with Artisan. One of the recent ones I’ve found is when you’re creating a CRUD record and need to create Model + Controller. You don’t need two separate commands for that.

How I was doing it until now:

Apparently, there’s a quicker way:

And that’s it. Laravel will actually ask you if you want to generate the model:
laravel controller model artisan
That’s it, quick tip to perform quick operation!

Want more tips and articles like this?
20-50 useful links every week on our weekly newsletter - comes out every Thursday!



4 thoughts on “Create Controller and Model in one Artisan Command

  1. On new models I start with:

    php artisan make:model Modelname -crm

    -crm = Create a controller as ressource and the migration file

Leave a Reply

Your email address will not be published. Required fields are marked *