title: Laravel: Argument 2 passed to Illuminate\Auth\SessionGuard::__construct()
body: <p>I have a application where I have created a new guard called <code>residents</code> which is the exact copy of the default <code>User</code> class that comes with the laravel. But when i change the guard it start showing this error:<br />
  <code>Argument 2 passed to Illuminate\Auth\SessionGuard::__construct() must be an instance of Illuminate\Contracts\Auth\UserProvider, null given, called in ...\vendor\laravel\framework\src\Illuminate\Auth\AuthManager.php on line 125</code></p>
  <p>I tried googling for the solution and read many but nothing worked.</p>
  <p>Laravel version is 5.8</p>
  <p><strong>auth.php</strong></p>
  <pre><code>'defaults' =&gt; [
      'guard' =&gt; 'web',
      'passwords' =&gt; 'users',
  ],
  
  'guards' =&gt; [
      'web' =&gt; [
          'driver' =&gt; 'session',
          'provider' =&gt; 'users',
      ],
  
      'api' =&gt; [
          'driver' =&gt; 'token',
          'provider' =&gt; 'residents',
          'hash' =&gt; false,
      ],
  ],
  
  'providers' =&gt; [
      'residents' =&gt; [
          'driver' =&gt; 'eloquent',
          'model' =&gt; App\ApiModels\Resident::class,
      ],
  ],
  
  'passwords' =&gt; [
      'users' =&gt; [
          'provider' =&gt; 'users',
          'table' =&gt; 'password_resets',
          'expire' =&gt; 60,
      ],
  ],
  </code></pre>
  <p><strong>App\ApiModels\Resident.php</strong></p>
  <pre><code>namespace App\ApiModels;
  
  use \Illuminate\Notifications\Notifiable;
  use \Illuminate\Contracts\Auth\MustVerifyEmail;
  use \Illuminate\Foundation\Auth\User as Authenticatable;
  
  class Resident extends Authenticatable
  {
      use Notifiable;
  
      /**
       * The attributes that are mass assignable.
       *
       * @var array
       */
      protected $fillable = [
          'name', 'email', 'password',
      ];
  
      /**
       * The attributes that should be hidden for arrays.
       *
       * @var array
       */
      protected $hidden = [
          'password', 'remember_token',
      ];
  
      /**
       * The attributes that should be cast to native types.
       *
       * @var array
       */
      protected $casts = [
          'email_verified_at' =&gt; 'datetime',
      ];
  
      /**
       * Authenticate the user
       *
       * @param   object  $request 
       * @return  array
       */
      public function _login($request)
      {
          if(\Auth::attempt([
              'email'    =&gt; $request-&gt;email,
              'password' =&gt; $request-&gt;password
          ]))
          {
              return [
                  'success' =&gt; true
              ];
          }
          else
          {
              return [
                  'success' =&gt; false
              ];
          }
      }
  }
  </code></pre>
  <p><strong>route\api.php</strong></p>
  <pre><code>Route::get('/login', 'Api\ResidentsController@login');
  </code></pre>
  <p><strong>Api\ResidentsController.php</strong></p>
  <pre><code>namespace App\Http\Controllers\Api;
  
  use Illuminate\Http\Request;
  use App\Http\Controllers\Controller;
  
  /**
   * Models
   */
  use App\ApiModels\Resident;
  
  class ResidentsController extends Controller
  {
      public function __construct()
      {
          /**
           * Middleware(s)
           */
          $this-&gt;middleware('auth:api', [
              'except' =&gt; [
                  'login',
                  'logout'
              ]
          ]);
      }
      
      public function login(Request $request)
      {
          ...
  
          return response()-&gt;json([
              'login_id' =&gt; $request-&gt;login_id,
              'password' =&gt; $request-&gt;password
          ]);
      }
  }
  </code></pre>