ollieread / multiauth

Laravel multi auth
441 stars 109 forks source link

How to get Eloquent user() object? From Auth::user() #67

Closed rajanrawal closed 9 years ago

rajanrawal commented 9 years ago

With Auth::user()->get() I am able to get the properties of the User Class but I am not able to access the relationships, obvious thing is that it returns me a Illuminate\Auth\GenericUser class. What is I want to get a User Class ( The main model ) Object? As because I want to access the other functions of User model, mostly relationships

ollieread commented 9 years ago

Have you verified that it returns GenericUser?

rajanrawal commented 9 years ago

Yes. I did dd(Auth::user()->get()); On Nov 28, 2014 5:35 PM, "Ollie Read" notifications@github.com wrote:

Have you verified that it returns GenericUser?

— Reply to this email directly or view it on GitHub https://github.com/ollieread/multiauth/issues/67#issuecomment-64887288.

pdcmoreira commented 9 years ago

So, how to solve this? I'm trying to:

$document->creator()->associate(Auth::user()->get());

Output:

Argument 1 passed to Illuminate\Database\Eloquent\Relations\BelongsTo::associate() must be an instance of Illuminate\Database\Eloquent\Model, instance of Illuminate\Auth\GenericUser given, called in  (...)