Reputation: 1511
In my routes on web.php I have the following line
Route::get('/', 'DashboardController@create')->name('dashboard');
In my DashboardController.php I have a create
function with the following line like I saw on a Laracast tutorial but it's not working.
return redirect()->dashboard();
I get the following error
(1/1) FatalThrowableError
Call to undefined method Illuminate\Routing\Redirector::dashboard()
What could I be doing wrong?
Upvotes: 2
Views: 1258
Reputation: 738
Instead of:
return redirect()->dashboard();
Try:
return redirect()->route('your-route-name');
Upvotes: 0
Reputation: 3935
return redirect()->dashboard();
calls a method named as dashboard
inside your controller and that's what error is saying
(1/1) FatalThrowableError
Call to undefined method Illuminate\Routing\Redirector::dashboard()
You need to call named routes like this
return redirect()->route('dashboard');
For deep insight always trust laravel docs
Upvotes: 0
Reputation: 174
You should use
return redirect()->route('dashboard');
this is the way to do it.
visit Named Routes for more info
Upvotes: 5