Posted by Arjun on Sunday 17th December 2017

Laravel 5.6 - New @method and @csrf Blade Directives

Laravel 5.x Laravel 5.6 @method @csrf

Laravel is gonna introduce two new Blade Directives as part of 5.6 release, @method and @csrf Directives.

In the current Laravel 5.5 version, we are doing the following at the top of forms to create hidden inputs for the CSRF token and the spoofed HTTP method -

<form>
  {{ csrf_field() }}
  {{ method_field('PUT') }}
  .....
  .......
  ......
</form>

In the Version 5.6, you can use new Blade Directives as shown below to create hidden inputs for the CSRF token and the spoofed HTTP method

<form>
  @method('put')
  @csrf
  .....
  .......
  ......
</form>

Below is the reference link -
https://github.com/laravel/framework/commit/5f1984421af096ef21b7d2011949a233849d4ee3