Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel resource controller difference between edit and update

Tags:

rest

laravel

In laravel when using Route::resource() the controller contains 7 methods. I am unsure what the differences are between the edit and update methods / resources.

GET         /resource/{resource}/edit   edit    resource.edit
PUT/PATCH   /resource/{resource}        update  resource.update

In my understanding of REST, it seems laravels update implementation is fairly standard while the edit route I can't see to think of a scenario to use it when returning resources as JSON.

like image 481
myol Avatar asked May 24 '16 13:05

myol


1 Answers

The difference is that edit is used to return the HTML form that is used to edit the resource values (notice that it responds to GET requests), while updateis the "action" that the edit form will be submitting to, and it responds to PUT or PATCH requests.

like image 71
Khalid Dabjan Avatar answered Oct 09 '22 21:10

Khalid Dabjan