1

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?

Chris
  • 54,599
  • 30
  • 149
  • 186
  • Check the response here: http://stackoverflow.com/questions/21660791/what-is-the-main-difference-between-patch-and-put-request – naneri Dec 30 '15 at 10:16
  • Thanks naneri, but my question is more to why they are separated in laravel as routes, yet both map to a single update method – Chris Dec 30 '15 at 10:52

1 Answers1

2

The RFCs define the differences between PUT vs PATCH, and the information for that is out there. One example is the answer linked to in the comments (example). However, for the Laravel framework, there really is no difference.

In regards to your second question, why PUT and PATCH are not merged in the routes, it is really just an oversight. This oversight has been corrected in Laravel 5.2, according to this pull request. Therefore, as of 5.2, the PUT and PATCH routes should show up merged, just like the GET and HEAD routes.

Community
  • 1
  • 1
patricus
  • 59,488
  • 15
  • 143
  • 145
  • 1
    I'm comfortable enough with the difference between `PUT` and `PATCH`, more confused about why they are seperate routes even though they map to the same controller update method. The second part of your answer resolved that confusion - namely that it is an oversight. Thanks – Chris Dec 30 '15 at 10:53