Laravel route from controller

I call the get_started route after a successful login:

protected $redirectTo = '/getting_started';

Here is my get_started route code:

Route::get('/getting_started','UserController@getting_started');

And the 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 fine and appears in the url:

http: // localhost: 8080 / getting_started

Now I really want if if user.dashboardview makes a call in url, for example:

http: // localhost: 8080 / dashboard `

And to getting_startedshow the view:

http: // localhost: 8080 / getting_started

You can call the dashboard route, and not:

  return view('user.dashboard');

My dashobard route:

Route::get('/dashboard',['middleware' => 'auth', function () {
    return view('user.dashboard');
}]);
+4
source share
2 answers

I understand that you are looking for this feature

return redirect()->route('dashboard');

, . , - .

+5

, user.dashboard, redirect()->route(route_name):

return redirect()->route('user.dashboard');

, .

0

All Articles