Laravel-mongodb: Laravel auth (getDateFormat() error)

Created on 1 Aug 2016  路  5Comments  路  Source: jenssegers/laravel-mongodb

Hello, I am using the native Laravel auth (from Laravel 5.2) and I am getting the following error:

BadMethodCallException in Model.php line 3001:
Call to a member function getDateFormat() on a non-object (null)
in Model.php line 3001
at Model->getDateFormat() in Model.php line 2921
at Model->fromDateTime(object(Carbon)) in Model.php line 2878
at Model->setAttribute('updated_at', object(Carbon)) in Model.php line 3420
at Model->__set('updated_at', object(Carbon)) in Model.php line 1771
...

Any ideas on where to fix?

Thanks,
David

Most helpful comment

It is not very good idea to modify files in vendor folder. Instead you should fork package or just copy that class somewhere in your app directory, modify it for your needs and extend your user model by this copied class.

All 5 comments

I finally fixed that using the CammoKing pull. I had to fix some issues with the MongoDBAuthServiceProvider file that was renamed to AuthServiceProvider. And after using the following auth provider:
'users' => [
'driver' => 'mongodb',
'model' => Jenssegers\Mongodb\Auth\UserModel::class,
'table' => 'users',
]
The register works, login and logout works. Now I'm having issues with the reset password.

UnexpectedValueException in PasswordBroker.php line 238:
User must implement CanResetPassword interface.

God damn! it is harder than I thought....

Same issue here, but its fun !

For Laravel 5.3

Call to a member function getDateFormat() on nul

In the file vendor/laravel/framework/src/Illuminate/Foundation/Auth/User.php

Replace use Illuminate\Database\Eloquent\Model; for this
use Jenssegers\Mongodb\Eloquent\Model as Model;

Its Works

It is not very good idea to modify files in vendor folder. Instead you should fork package or just copy that class somewhere in your app directory, modify it for your needs and extend your user model by this copied class.

not work for me

Was this page helpful?
0 / 5 - 0 ratings

Related issues

YSimple picture YSimple  路  3Comments

Vasiliy-Bondarenko picture Vasiliy-Bondarenko  路  3Comments

geofflancaster picture geofflancaster  路  3Comments

pirmax picture pirmax  路  3Comments

tomartailored picture tomartailored  路  3Comments