Recently I've started with Laravel 5.2 and I'm trying to make delete button which will delete row from database. Very basic and trivial but seems I can't make it.
I'm following documentation for delete: http://ift.tt/2iH8tpb
And I have made this. My route:
Route::post('flags/destroy/{delete}', 'FlagsController@destroy')->name('admin.flags.destroy');
Button in the view
{!! Html::linkRoute('admin.flags.destroy', 'Delete', $flag->report_id) !!}
and the controller
public function destroy(Request $request){
$report = $request['report_id'];
Report::find($report);
$report->delete();
$request->session()->flash('alert-success', ' Report is deleted successfully.');
return redirect()->route('admin.flags');
}
I've tried solutions from other threads but I always got error:
MethodNotAllowedHttpException in compiled.php line 8936:
New error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'reports.id' in 'where clause' (SQL: select * from `reports` where `reports`.`id` is null limit 1
Why is searching for id
instead of report_id
?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2jy1LFZ
via IFTTT
Aucun commentaire:
Enregistrer un commentaire