Strange pluralisation behavior for Route::resource

Posted 11 months ago by simar

I was creating a resource controller for optical lenses just the regular way with Artisan. No problems so far as I am using the singular form.

php artisan make:model Lens -mr

The migration file is called correctly 'create_lenses_table', the Schema creates the table 'lenses' and the controller is built the same way, using model binding with Lens $lens.


When adding the Route::resource, it's using the wrong parameter ({len} instead of {lens}), thus making the controller fail. The route listing looks like this:

|        | DELETE    | lens/{len}             | lens.destroy    | App\Http\Controllers\[email protected]                      | web  |
|        | GET|HEAD  | lens/{len}             |       | App\Http\Controllers\[email protected]                         | web  |
|        | PUT|PATCH | lens/{len}             | lens.update     | App\Http\Controllers\[email protected]                       | web  |
|        | GET|HEAD  | lens/{len}/edit

Am I missing something? Of course it's possible to solve with a workaround, but nevertheless it's an unwanted behavior, imho.

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