title: What is the better way to set Auth::user() object in Laravel controller's constructor
body: <p><strong>Laravel's Php Artisan Route:list will throw exception when we instantiate Auth::user() in controller constructor</strong></p>
  
  <p>When you run php artisan route:list, Laravel instantiates all controllers to check, if they declare a middleware - it's usually done in constructor by a call to middleware() method. At this point, there is no user session, therefore Auth::user() won't return anything, and we will getting an error trying to access name property on non-object.     </p>
  
  <p>Example:  </p>
  
  <pre><code>     class settingController extends Controller
      {
          protected $user;
  
          public function __construct(ImageRepo $image)
          {
              $this-&gt;user =  Auth::user();
              $this-&gt;image = $image;
          }
  ......
  </code></pre>
  
  <p><strong>Exception</strong></p>
  
  <pre><code>C:\laragon\www\water2&gt;php artisan route:list -v
  
  
    [Symfony\Component\Debug\Exception\FatalErrorException]                                                     
    Cannot use Illuminate\Contracts\Auth\Authenticatable as Authenticatable because the name is already in use  
  </code></pre>
  
  <p>What is the better way to store User Object?</p>
  
  <p><strong>Reference</strong> </p>
  
  <p><a href="https://stackoverflow.com/questions/34350726/i-get-the-error-in-php-artisan-routelist-command-in-laravel/37572190#37572190">I get the error in php artisan route:list command in laravel?</a></p>
  
  <blockquote>
    <p>@jedrzej.kurylo You shouldn't access user object in the constructor, do that in action methods.</p>
  </blockquote>
  
  <p>But how?</p>