Reputation: 441
I am calling getting_started route after successfully login :
protected $redirectTo = '/getting_started';
Here is my getting_started route code :
Route::get('/getting_started','UserController@getting_started');
And controller code :
public function getting_started()
{
$id= Auth::id();
$user = DB::table('user_profiles')->where('user_id', '=', $id)->first();
if($user->dashboard_access == 0)
{
DB::table('user_profiles')
->where('user_id', $id)
->update(['dashboard_access' => 1]);
return view('user.getting_started');
}
return view('user.dashboard');
}
It works perfectly and show in url :
Now I actually want that if user.dashboard
view is call it show in url like :
And on getting_started
view show :
It is possible to call dashboard route instead of :
return view('user.dashboard');
My dashobard route is :
Route::get('/dashboard',['middleware' => 'auth', function () {
return view('user.dashboard');
}]);
Upvotes: 10
Views: 41348
Reputation: 1043
What I understand it is that you are looking for is this function
return redirect()->route('dashboard');
It's my understanding of your question which can be wrong. Maybe you are asking something else.
Upvotes: 17
Reputation: 67505
That called Redirection and especially you want to Returning A Redirect To A Named Route, you route called user.dashboard
so you could redirect to it using redirect()->route(route_name)
:
return redirect()->route('user.dashboard');
Hope this helps.
Upvotes: 1