Laravel PHP Developer Question:
Download Job Interview Questions and Answers PDF
Do you know what is Method Spoofing in Laravel?
Answer:
As HTML forms does not supports PUT, PATCH or DELETE request. 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:
<form action="/foo/bar" method="POST">
<input type="hidden" name="_method" value="PUT">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>
To generate the hidden input field _method, you may also use the method_field helper function:
<?php echo method_field('PUT'); ?>
In Blade template you can write it as below
{{ method_field('PUT') }}
<form action="/foo/bar" method="POST">
<input type="hidden" name="_method" value="PUT">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
</form>
To generate the hidden input field _method, you may also use the method_field helper function:
<?php echo method_field('PUT'); ?>
In Blade template you can write it as below
{{ method_field('PUT') }}
Download Laravel PHP Developer Interview Questions And Answers
PDF
Previous Question | Next Question |
Tell me what are pros and cons of using Laravel Framework? | Tell me is Laravel An Open Source? |