Okay so guys i've a problem when working with laravel's update & i've spent 3 days and no one can solve my problem too so i decide to ask you all pro coder, please kindly help me
First, this is part of my View (editkeluhan.blade.php)
<form class="form-horizontal" role="form" method="POST" action="{{ url('/editkeluhanadmin/{$keluhan->id}') }}" enctype="multipart/form-data">
{{ csrf_field() }}
<div>
<input name="_method" type="hidden" value="PATCH">
</div>
Second, This is my Route
Route::get('editkeluhan/{id}','AdminController@editkeluhan');
Route::post('editkeluhanadmin/{id}', 'AdminController@updatekeluhanadmin');
public function editkeluhan($id){
$halaman="tindaklayanan";
$keluhan=keluhan::findOrFail($id);
return view('layanankonsumen.editkeluhan',compact('keluhan','halaman'));
}
public function updatekeluhanadmin(Keluhan $keluhan, Request $r){
$halaman = 'tindaklayanan';
$keluhan->update($r->all());
return redirect('/');
Third, this is AdminController
public function editkeluhan($id){
$halaman="tindaklayanan";
$keluhan=keluhan::findOrFail($id);
return view('layanankonsumen.editkeluhan',compact('keluhan','halaman'));
}
public function updatekeluhanadmin(Keluhan $keluhan, Request $r){
$halaman = 'tindaklayanan';
$keluhan->update($r->all());
return redirect('/');
}
This is ERROR, but when i change my Route into this
Route::resource('editkeluhanadmin', 'AdminController@updatekeluhanadmin');
Error is gone BUT Its not update in database
Please Please Help me