Randy_Johnson
4 months ago
367
4
General

Auth Null Inside Constructor

Posted 4 months ago by Randy_Johnson

Hello, I am having trouble with the

//Not working
    public function __construct() 
    {
        $user = Auth::user();
        dd($user);
    }

inside my constructor, I was just wondering was it is empty or to be more specific, why does it return null, where has if I am to run it in my index I have all data returned perfectly. I tried searching for an explanation and have no answer.

//Working
    public function index() 
    {
        $user = Auth::user();
        dd($user);
    }

And the web.php

Auth::routes();

// User
Route::namespace('TTobacco\Customer')->prefix('user')->name('user.')->middleware('auth')->group(function () {

    // TTobacco User Area
    Route::get('/home', '[email protected]');

Please sign in or create an account to participate in this conversation.