Because HTML forms do not support PUT, PATCH and DELETE and other actions, so On Laravel
When submitting the HTML form, we need to send it as an HTTP request through a hidden _method input field.
In this way, Laravel's Restful style routing can know whether the request is PUT or PATCH...etc.
Prior to Laravel 5.5, forms could embed two hidden input fields:
<form action="/foo/bar" method="POST">
<input type="hidden" name="_method" value="PUT">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>
or
<form action="/foo/bar" method="POST">
{{ method_field('PUT') }}
{{ csrf_field() }}
</form>
After Laravel 5.6, we can also achieve the same effect through Blade directive:
<form action="/foo/bar" method="POST">
@method('PUT')
@csrf
</form>
No Comment
Post your comment