title: Single API use for authenticated and guest user
body: <p>My laravel application route configured on routes/api.php is.</p>
  
  <pre><code>&lt;?php
  use Illuminate\Http\Request;
  Route::post('see_all_product',  'API\ProductController@see_all_product');
  ?&gt;
  </code></pre>
  
  <p>Issue is i want to sent list of product but if user authenticated then send  product favorite flag 1, and if not authenticated then send return favorite 0</p>
  
  <p>But both case send product list with favorite flag.</p>
  
  <p>If i logged in with my user id and password and send request for <strong>see_all_product</strong> that time i m getting blank user.</p>
  
  <pre><code>$user = $request-&gt;user();
  </code></pre>
  
  <p>But if i set route like below i m getting user details.</p>
  
  <pre><code>&lt;?php
  use Illuminate\Http\Request;
  Route::group(['middleware' =&gt; 'auth:api'], function(){
          Route::post('see_all_product',  'API\ProductController@see_all_product');
  });
  ?&gt;
  </code></pre>
  
  <p>Now issue is how can i get details if authorization set in the header with same api.</p>
  
  <pre><code>&lt;?php
  use Illuminate\Http\Request;
  Route::post('see_all_product',  'API\ProductController@see_all_product');
  ?&gt;
  </code></pre>
  
  <p>My <strong>see_all_product</strong> Function</p>
  
  <pre><code>public function see_all_product(Request $request){ 
      try { 
          $user = $request-&gt;user(); 
      } catch (Exception $ex) { 
          Log::error($ex); 
      }
  }
  </code></pre>
  
  <p>API is same for both authenticated and guest user.</p>
  
  <p>I pass authorization token in both case but middleware route i get user details but non middleware route i dont get user information.</p>
  
  <p>Please guide me where i can miss something?</p>