Laravel Routing: Form Method Spoofing

<form action="https://laravel.com/foo/bar" method="POST">
    <input type="hidden" name="_method" _cke_saved_name="_method" value="PUT">
    <input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>
<form action="https://laravel.com/foo/bar" method="POST">
    @method('PUT')
    @csrf
</form>
  • So, when defining PUT, PATCH or DELETE routes that are called from an HTML form, you will need to add a hidden _method field to the form.
  • The value sent with the _method field will be used as the HTTP request method.
  • Ou may use the @method Blade directive to generate the _method input.

@method Blade directive

<form action="https://laravel.com/foo/bar" method="POST">
    @method('PUT')
    @csrf
</form>

Laravel Routing: Form Method Spoofing — Structure map

Clickable & Draggable!

Laravel Routing: Form Method Spoofing — Related pages: