laravel resource controllers / routes and models

Viewed 3232

So if you do something like

$ artisan make:model TurboClown
$ artisan make:controller TurboClownController -r --model=TurboClown

So at this point it's possible to add something like:

Route::resource('clowns','TurboClownController');

To your routes/web.php. Now I have routes like clowns/{clown} when I routes:list with artisan.

However, my show function is like:

    public function show(TurboClown $turboClown)

Which when you return $turboClown will just give [] as a response when you request "/clowns/3/" for example. It took me a while to figure out that if I change $turboClown parameter to $clown, I get a JSON TurboClown as a response.

So in a sense, I solved my problem. But I'm curious about a couple points:

  1. To me, https://laravel.com/docs/5.4/controllers#restful-naming-resource-route-parameters reads as if I could add ['parameters' => ['clown' => 'turboClown'] and then show() would work using "turboClown", but it does not.

  2. According to https://laravel.com/docs/5.4/routing#route-parameters : " Route parameters are injected into route callbacks / controllers based on their order - the names of the callback / controller arguments do not matter." But it looks like the name of the parameter does matter in this case?

So I am looking for some kind of clarification on those two points, what am I missing?

1 Answers
Related