Answer the question
In order to leave comments, you need to log in
Where can I use Auth::user() in LARAVEL5?
how can I use Auth::user() in particular, I need it in AppServiceProvider or in routes
public function boot()
{
$userId = Auth::user()->id;
dd($userId);
$categories = Catigories::where('user_id','=',$userId)->get();
view()->share('categories', $categories);
}
Answer the question
In order to leave comments, you need to log in
the problem is that he does not see Auth::user() Trying to get property of non-objectHe sees everything perfectly . It's just that the user is not authorized, so it's impossible to get his id. Use Auth::check() first to check.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question