3 months ago

ASSISTENCE! - how to / auth in constructor /

Posted 3 months ago by santino

Hi, some one can give me a hit with this...

    public function __construct()
        $this->user = Auth::user();

am trying to make a global variable of USER inside the controller, but I cant get any ressult

when I call this

 return $this->user; 

nothing happens if I call like this

return Auth::user();

I got the user... Some one know how to manage this?

the thing is I end up with this

    public function welcome()

        $page_title = 'welcome';
        $page_description = '• this is the main web page';
        $user = Auth::user();
       // return $this->user;

        return view('pages.welcome', compact('page_title', 'page_description' , 'user'  ));


BUT I DONT WANT TO CALL user auth::users on each single function to call each next pages... that is repeating and repeting

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