Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel call route from controller

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 :

http://localhost:8080/getting_started

Now I actually want that if user.dashboard view is call it show in url like :

http://localhost:8080/dashboard`

And on getting_started view show :

http://localhost:8080/getting_started

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');
}]);
like image 307
Umair Zahid Avatar asked Mar 02 '16 10:03

Umair Zahid


1 Answers

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.

like image 147
Yasir Ijaz Avatar answered Oct 06 '22 00:10

Yasir Ijaz