I'm still learning Laravel and I'm working with version 5.4. I'm currently trying to perform an update and want to see the contents of the request using dd, but I get redirected to the view page (strange). I compared the documentation and I seem to be doing right. Below is the captured url when i submit the update form
http://127.0.0.1:8000/tasks/2?_token=gX4bBZoZ0bpMgeQ5uIbLNrIegohvAOUJmPTNjbX0&_method=PUT&employee_id=Harry+Ovie&title=update&description=Testing+task&priority=high&begin=2017%2F06%2F02&end=2017%2F06%2F05
This is my route list
Route::get('/tasks', 'TaskController@index');
Route::get('/tasks/create', 'TaskController@create');
Route::post('/tasks', 'TaskController@store');
Route::get('/tasks/{id}', 'TaskController@show');
Route::get('/tasks/{id}/edit', 'TaskController@edit');
Route::put('/tasks/{id}', 'TaskController@update');
This is the update in my TaskController
public function update(Request $request, $id)
{
dd($request);
}
And this is what my form looks like
<form class="form-horizontal" role="form" action='/tasks/{{$task->id}}'>
{{ csrf_field() }}
<input name="_method" type="hidden" value="PUT">
How do i fix my code?
Try posting your form, right now you're performing a GET.
<form class="form-horizontal" role="form" method="post" action='/tasks/{{$task->id}}'>
HTML forms do not support the use of PUT, PATCH and DELETE (and some others). That's why the hidden field is added and handled by Laravel to perform these actions on a POST request.