Laravel 5.2:Route [WelcomeController.destroy]未定义

时间:2016-05-06 14:33:52

标签: php laravel laravel-5 laravel-5.2 laravel-routing

在我的路线中:

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)

1 个答案:

答案 0 :(得分:2)

您应该在视图中使用welcome.destroy代替WelcomeController.destroy

为了验证路线的名称,您始终可以运行:

php artisan route:list您将看到Laravel应用程序中所有路线的名称