title: Conditionally redirect users after login in laravel backpack
body: <p>I have some roles asigned to users. I would like to have a user redirected after login to different urls in order the role that user belongs to.
  I have followed this post but it didn't work to me. I don't know if using backpack it would be different.</p>
  
  <p>Best regards.</p>
  
  <p>Edit.</p>
  
  <p>This is the code in the login controller.</p>
  
  <pre><code>&lt;?php
  
  namespace Backpack\Base\app\Http\Controllers\Auth;
  
  use Backpack\Base\app\Http\Controllers\Controller;
  use Illuminate\Foundation\Auth\AuthenticatesUsers;
  use Illuminate\Http\Request;
  
  class LoginController extends Controller{
  protected $data = []; // the information we send to the view
  
  protected $redirectTo = '/home';
  
  /*
  |--------------------------------------------------------------------------
  | Login Controller
  |--------------------------------------------------------------------------
  |
  | This controller handles authenticating users for the application and
  | redirecting them to your home screen. The controller uses a trait
  | to conveniently provide its functionality to your applications.
  |
  */
  use AuthenticatesUsers {
      logout as defaultLogout;
  }
  
  protected function authenticated(Request $request, $user){
      /*if ( $user-&gt;isAdmin() ) {// do your margic here
          return redirect('/home1');
      }*/
  
      return redirect('/myhome');
  }
  
  /**
   * Create a new controller instance.
   *
   * @return void
   */
  public function __construct()
  {
      $guard = backpack_guard_name();
  
      $this-&gt;middleware("guest:$guard", ['except' =&gt; 'logout']);
  
      // ----------------------------------
      // Use the admin prefix in all routes
      // ----------------------------------
  
      // If not logged in redirect here.
      $this-&gt;loginPath = property_exists($this, 'loginPath') ? $this-&gt;loginPath
          : backpack_url('login');
  
      // Redirect here after successful login.
      $this-&gt;redirectTo = property_exists($this, 'redirectTo') ? $this-&gt;redirectTo
          : backpack_url('dashboard');
  
      // Redirect here after logout.
      $this-&gt;redirectAfterLogout = property_exists($this, 'redirectAfterLogout') ? $this-&gt;redirectAfterLogout
          : backpack_url();
  }
  
  /**
   * Return custom username for authentication.
   *
   * @return string
   */
  public function username()
  {
      return backpack_authentication_column();
  }
  
  /**
   * Log the user out and redirect him to specific location.
   *
   * @param \Illuminate\Http\Request $request
   *
   * @return \Illuminate\Http\Response
   */
  public function logout(Request $request)
  {
      // Do the default logout procedure
      $this-&gt;guard()-&gt;logout();
  
      // And redirect to custom location
      return redirect($this-&gt;redirectAfterLogout);
  }
  
  /**
   * Get the guard to be used during logout.
   *
   * @return \Illuminate\Contracts\Auth\StatefulGuard
   */
  protected function guard()
  {
      return backpack_auth();
  }
  
  // -------------------------------------------------------
  // Laravel overwrites for loading backpack views
  // -------------------------------------------------------
  
  /**
   * Show the application login form.
   *
   * @return \Illuminate\Http\Response
   */
  public function showLoginForm()
  {
      $this-&gt;data['title'] = trans('backpack::base.login'); // set the page title
      $this-&gt;data['username'] = $this-&gt;username();
  
      return view('backpack::auth.login', $this-&gt;data);
  }
  }
  </code></pre>
  
  <p>If I put this code in the path </p>
  
  <pre><code>vendor\backpack\base\src\app\Http\Controllers\Auth\LoginController.php
  </code></pre>
  
  <p>It works fine. But If I put the code in </p>
  
  <pre><code>app\Http\Controllers\Auth\LoginController.php
  </code></pre>
  
  <p>It does not work</p>
  
  <p>I'm trying to extend the controller like this</p>
  
  <pre><code>use Backpack\Base\app\Http\Controllers\Auth\LoginController as OriginalLoginController;
  
  class MyLoginController extends OriginalLoginController{
  
   .....
  }
  </code></pre>