mercredi 30 décembre 2015

Why does a Laravel resource controller limited to update generate two routes?

Given the following defined route in routes.php:

Route::resource('smoker','SmokerController',['only' => ['update']]);

..results in the generation of two distinct routes:

| PUT   | profile/smoker/{smoker}| profile.smoker.update | App\Http\Controllers\Profile\SmokerController@update |
| PATCH | profile/smoker/{smoker}|                       | App\Http\Controllers\Profile\SmokerController@update |

I can hazard a guess that both PUT and PATCH verbs are close enough in a restful environment that they both fall under an 'update' restriction. I can't find any documentation to support that guess, nor can I find anywhere documentation why one (PUT) has it's alias automatically set, in this case, to profile.smoker.update.

What is more confusing, is that a similar restriction, 'show', results in a verbs GET and HEAD being merged as GET|HEAD in the route list.

| GET|HEAD | profile/smoker/{smoker}| profile.smoker.show | App\Http\Controllers\Profile\SmokerController@show |

Why is GET and HEAD merged, but PUT and PATCH not?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire