I've been reading so many resources about the HTTP methods differences and the exact advantages As far as I got,it seems like a contract for better understanding and working with REST API. My confusion is as followings :
I have a form :
<form action="{{ route('test') }}" method="POST">
@csrf
@method('PUT')
<input type="text" name="input1" >
<input type="text" name="input2" >
<button type="submit">send </button>
</form>
I have a table like this :
| id | input1 | input2 | input3
| -- | ----- | ------ |----|
| 1 | 100 | 220 | 400
in controller I update all request fields which we sent.
public function test(Request $request)
{
return Setting::find(1)->fill( $request->all())->save();
}
All PUT,PATCH,POST methods worked the same way.
PUT does not change input3 to the NULL if it's supposed to regenerate resource totally.
and PATCH changes input1 and input2.
POST also works the same because I noted the resource ID.
the question is so what is the exact DIFF? The resources is telling us that :
create - POST
read - GET
update - PUT
modify - PATCH
delete - DELETE
while we can update,modify or even delete by using POST.
when we are using form request ,the sent data is exactly the same .
We heard that PUT method regenerate resource totally , while it does not happen and it only updates the sent fields in DB( only updated Input1 and input2 in above example)
I think they will work when we are not using forms with all input and when we are sending the data partially .
Are there any other deep and obvious differences in implementation ?