1

Reading Jenssegers mongodb documentation i have install this module to get access to mongodb functions. In first step I configure user login/registration issues and after catch this error.

`Trying to get property of non-object ... array('guard' => null)

I need to get current user Id in custom controller:

use Auth;

//method

...

Auth::guard('site')->user();

...

//

But I get NULL from Auth::user(). All data is set in Auth ([Auth][SessionGuard][User]) and exist, but here i see issue about _id field in [user] object from table. So native user() method want find id field in object. How can I change old id to _id to get user()? Anybody had this issue before?

1 Answers1

0

verify your user model:

*//
use Jenssegers\Mongodb\Auth\User as Authenticatable;

class User extends Authenticatable{
/* */
}*

If you are using api routes, try change your middleware in app\http\routeServiceProvider.php in mapApiRoutes() function

->middleware('api')

to:

->middleware('web')