title: Can't get user id in controller and Auth::check() is not working - Laravel 5.8
body: <p>I am new to laravel 5.8 , am not able to use <code>Auth</code> in api controllers, below are the details : </p>
  
  <ol>
  <li>I have changed default users table from <code>users</code> to <code>User</code></li>
  </ol>
  
  <p><strong>User.php</strong></p>
  
  <pre><code>&lt;?php
  
      namespace App;
  
      use Illuminate\Notifications\Notifiable;
      use Illuminate\Contracts\Auth\MustVerifyEmail;
      use Illuminate\Foundation\Auth\User as Authenticatable;
  
      class User extends Authenticatable
      {
          use Notifiable;
          protected $table = 'User';
  
          /**
           * The attributes that are mass assignable.
           *
           * @var array
           */
          protected $fillable = [
              'firstName', 'lastName', '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',
          ];
      }
  </code></pre>
  
  <ol start="2">
  <li><p>Did not change anything in <strong>auth.php</strong></p>
  
  <pre><code>&lt;?php 
    return 
  
  ['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; 'users',
          'hash' =&gt; false,
      ],
  ],
  
  'providers' =&gt; [
      'users' =&gt; [
          'driver' =&gt; 'eloquent',
          'model' =&gt; App\User::class,
      ],
  
      // 'users' =&gt; [
      //     'driver' =&gt; 'database',
      //     'table' =&gt; 'users',
      // ],
  ],
  
  'passwords' =&gt; [
      'users' =&gt; [
          'provider' =&gt; 'users',
          'table' =&gt; 'password_resets',
          'expire' =&gt; 60,
      ],
  ], 
  ];
  </code></pre></li>
  </ol>
  
  <p>My question : How can I make <strong>Auth::check()</strong> work in this controller and get user id. This returns <code>Not logged</code></p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers\api;
  
  use Illuminate\Http\Request;
  use App\Http\Controllers\Controller;
  
  use Session;
  use DB;
  use Response;
  
  use Auth;
  
  class AccountsController extends Controller
  {
      /**
       * Display a listing of the resource.
       *
       * @return \Illuminate\Http\Response
       */
      public function index()
      {   
           //
          $userID = Auth::id();
  
          if (Auth::check()) {
              return "User logged , user_id : ".$userID ;
          }else{
              return "Not logged"; //It is returning this
          }
      }
  
  }
  </code></pre>
  
  <p>I have tried several answers of similar questions ( <a href="https://stackoverflow.com/questions/31575854/laravel-auth-user-id-in-controller">Q1</a> <a href="https://stackoverflow.com/questions/54970541/using-authuser-user-in-laravel-5-8-or-later">Q2</a> ) but it didn't work.</p>