在我的路线中:
Route::resource('welcome', 'WelcomeController');
查看:
{{ Form::open(['method' => 'DELETE', 'route' =>['WelcomeController.destroy', $task->id]]) }}
{{ Form::submit('Delete', ['class' => 'btn btn-danger']) }}
{{ Form::close() }}
WelcomeController
控制器:
public function destroy($id)
{
$task = Task::findOrFail($id);
$task->delete();
return back();
}
错误出现:
Route [WelcomeController.destroy] not defined. (View: /opt/lampp/htdocs/NewTask/resources/views/welcome.blade.php)
答案 0 :(得分:2)
您应该在视图中使用welcome.destroy
代替WelcomeController.destroy
。
为了验证路线的名称,您始终可以运行:
php artisan route:list
您将看到Laravel应用程序中所有路线的名称