1 year ago

Why does generated Controller with make:model has bad name?

Posted 1 year ago by octal

In Laravel, for a model named let's say

  • Product (model in singular) I'm assumed to have a
  • migration for a table Products -and a controller named ProductsController (note plural form).

The usual way I make all three is:

1- make the migration $php artisan make:migration create_products

2- make the model $php artisan make:model Product

3- make the conroller $php artisan make:controller ProductsController -m=Product

This works as expected. But when I check the artisan make:model command, I can see that it can create the migration and the controller in one shot. So I tried

$php artisan make:model Product --controller --migration -r

The problem is with this, is that the controller name is wrong, it's ProductController (singular) instead of ProductsController (plural form).

Am I wrong with using this command? or is the controller created with this command intended to be different from the one we create with make:controller ???


Please sign in or create an account to participate in this conversation.