Laravel 5.4路线名称不工作

Laravel 5.4路线名称不工作,laravel,laravel-5.4,laravel-routing,Laravel,Laravel 5.4,Laravel Routing,在我的web.php路由中,我有以下几行 Route::get('/', 'DashboardController@create')->name('dashboard'); 在我的DashboardController.php中,我有一个create函数,如下所示,就像我在Laracast教程中看到的那样,但它不起作用 return redirect()->dashboard(); 我得到以下错误 (1/1) FatalThrowableError Call to undefin

在我的web.php路由中,我有以下几行

Route::get('/', 'DashboardController@create')->name('dashboard');
在我的DashboardController.php中,我有一个
create
函数,如下所示,就像我在Laracast教程中看到的那样,但它不起作用

return redirect()->dashboard();
我得到以下错误

(1/1) FatalThrowableError
Call to undefined method Illuminate\Routing\Redirector::dashboard()
我可能做错了什么?

您应该使用

return redirect()->route('dashboard');
这是做这件事的方法

有关更多信息,请访问
返回重定向()->dashboard()
在控制器中调用名为
dashboard
的方法,这就是错误的意思

(1/1)fatalthrowable错误

调用未定义的方法 照亮\路由\重定向器::仪表板()

您需要像这样调用命名路由

return redirect()->route('dashboard');
要获得深刻的洞察力,请始终信任,而不是:

return redirect()->dashboard();
尝试:


我认为你应该做
redirect()->到('dashboard')
return redirect()->route('your-route-name');