Support the ongoing development of Laravel.io →
Authentication Laravel Configuration

Laravel Version: 5.6.*

PHP Version: 7.2.2

Database Driver & Version: Mysql 5.0.12

Description:

logged user in contruct method return null

Steps To Reproduce: I need return logged user in contruct method,

public function __construct(){

	$this->menu = new Menu();

	$this->menu->getEnabledMenu();

	$this->categories = $this->
	menu::with('children')->
	where('parent_id','=',0)->
	whereIn('id', [8,9,7])->
	orderBy('position', 'asc')->
	get();
}

i tried with $this->user->Auth::user()->id; but this doesn't work

i also tried this

https://laravel-news.com/controller-construct-session-changes-in-laravel-5-3

$this->middleware(function ($request, $next) {
        $this->user= Auth::user();

        return $next($request);
    });

but i I do not know how to access $this->user

please i need help

sorry for my english

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.