Not sure to really understand the question...
What is the difference between "editing" and "updating" in Resourceful Routing ?
I am routing back to my controller and my model. Editing and Updating amounts to the same thing surely, no ??
@vincej If you mean Edit and Update methods, the difference is significant. Edit is for displaying a form to apply changes and Update is used to set them up to server.
Edit is via GET http Update is via PUT http
Yup - I'm referring to methods and the associated form action. In CodeIgniter everything is POST or GET. So if I am changing or adding data to the table I would always choose POST.
I don't understand your sentence:
Update is using to set them up to server
The Edit returns a view of the resource being edited, the Update updates the resource it self.
Ok - got it. However, putting aside the semantics, I could use them interchangeably use them within my models and it would make little to no function difference, correct ?
To sum up :
POST
Requests that the server accept the entity enclosed in the request as a new subordinate of the web resource identified by the URI. The data POSTed might be, for example, an annotation for existing resources; a message for a bulletin board, newsgroup, mailing list, or comment thread; a block of data that is the result of submitting a web form to a data-handling process; or an item to add to a database.
PUT
Requests that the enclosed entity be stored under the supplied URI. If the URI refers to an already existing resource, it is modified; if the URI does not point to an existing resource, then the server can create the resource with that URI.
PATCH
Applies partial modifications to a resource.
@vincej you tell Laravel what to do with the requests in your routes file. So the answer I think depends on how you set it up. I think Laravel by default looks for Index, Show, Edit, Update, Delete. The easiest routing I do is
Route::resource('awesome', 'AwesomeController');
Thanks for that Every One,
Does it make any functional difference which verb you use, and what associated method you use, when the browsers only recognises POST and GET anyway?
secondly, why do you dispense with verbs and just use your simple form of routing ?
POST can send a large amount of data. PUT cannot. Many frameworks use POST. It's up to the server to decide on state and intention. I agree with you @vincej its just a semantic difference. When I edit I intend to either update or forget it.
Thanks all - my personal challenge is that I have spent too long with more simple frameworks like CodeIgniter and so I have to grasps these new Laravel nuances.
So, @jimmck in my form:open it is just fine to do the below and leave it as that ?
{!! Form::open(array( 'route'=>'locations.update')) !!}
@vincej As far as I am concerned yes. I use POST exclusively and always send messages. I am an old Windows developer after all. If a spec requires I use REST I would. But for Forms, I load 'em once. I hate watching HTML fly back and forth! Again old Windows developer.
If you use resources, You need to specify method as a hidden input.
// Please, excuse I don't use Form facade so don't remember notation for it
<input type='hidden' name='_method' value='PUT' />
Sending your request to Laravel without specifying method as PUT you won't access to update method.
There is no functional difference , it is a naming convention! I personally make my own apps with the default method names, so future developers don't need to think more, and of course I add more methods when if needed. In my routes file, I define all my routes either PUT PATCH POST DELETE
@bobbybouwmann And who will come to arrest me? How do you handle the browser based URL limit for a PUT? POST was created for Large Forms. Just saying. As @vinvcej has pointed out a matter of semantics and design choice.
Yea, of course but a good develop sticks to the best practices where possible ;)
Thanks Guys - the clouds have lifted.
I have in fact embraced resourceful routing as I find it convenient to have all the routes set up for me automagically. So, my big take away is that there is a difference between verbs in forms and I need to be specific with forms or else L5 will puke.
Now, putting all that aside, there is no functional difference when it comes to updating my DB whether I'm doing it through an Edit or an Update method in my model.
@bobbybouwmann "Yea, of course but a good develop sticks to the best practices where possible ;)" Could not agree more. And when needed I do. In the end my users only care it works. When I was a young'n I was on the trading floor and a user asked why something was not working. I gave him the technical answer. He smiled and turned to his desk mate and said, 'He's gone bits and bites on me"...
@vincej that is what I mean of
I think Laravel by default looks for Index, Show, Edit, Update, Delete.
Someone tell me the difference between EDIT and SHOW in Resourceful Routing. Both edit and show uses GET http. So what's the difference???
Please or to participate in this conversation.