在我在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()->dashboard();
在你的控制器中调用一个名为dashboard
的方法,这就是错误说的
(1/1)FatalThrowableError
调用未定义的方法Illuminate \ Routing \ Redirector :: dashboard()
您需要像这样调用命名路由
return redirect()->route('dashboard');
深刻见解总是信任laravel docs
代替:
return redirect()->dashboard();
尝试:
return redirect()->route('your-route-name');