0

Currently I'm trying to receive the entire object (model) from the user. Right now I'm doing it like this (for example if I want to receive the email) :

$email = Auth::user()->email;

But when I do this:

$user = Auth::all();

It doesn't work obviously I'm doing something wrong. I've already searched in the laravel documentation but can't find it. Could someone explain this to me?

Thanks.

2
  • Have you tried $user = Auth::user(); ? Commented Aug 25, 2015 at 21:16
  • Oke that was fast. Thanks worked! But why user(); ? Commented Aug 25, 2015 at 21:21

1 Answer 1

1

$user = Auth::user();

Auth is not a model! Also, I don't believe you: Documentation

Sign up to request clarification or add additional context in comments.

2 Comments

Oke thanks. Is it also possible to give that user object to for example a navbar that I've included in other views? I think it would be something like this? return compact('user')); ??
Sure you can pass it to the view like any other variable. Since you probably don't want to do that in every controller though, I recommend you look into View Composers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.