I've just installed laravel 5.3.16 And I've added composer require jenssegers/mongodb package to my project and configured it. then I've added composer require laravel/passport package to my project and I've followed this tutorial :
steps to make passport package work but when i'm running : php artisan passport:install
I get this error message :
PHP Fatal error: Call to a member function getDateFormat() on null in /usr/local/ampps/www/test5_3/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php on line 2992
Any idea how to fix it ?
https://github.com/jenssegers/laravel-mongodb/issues/947 ;)
Thanks
Hello,
i am also getting same error and i tried above solution but its not working out for me.
Any other solution?

@mohammad-69 have you solved this? please let me know the solution.
Search line use Illuminate\Database\Eloquent\Model; in the plugin passport path /httpdocs/vendor/laravel/passport
Replace Model line for this
use Jenssegers\Mongodb\Eloquent\Model as Model;
httpdocs/vendor/laravel/passport/src/AuthCode.php
httpdocs/vendor/laravel/passport/src/Client.php
httpdocs/vendor/laravel/passport/src/Http/Controllers/AuthorizationController.php
httpdocs/vendor/laravel/passport/src/Http/Controllers/ClientController.php
httpdocs/vendor/laravel/passport/src/Http/Controllers/RetrievesAuthRequestFromSession.php
httpdocs/vendor/laravel/passport/src/PersonalAccessClient.php
httpdocs/vendor/laravel/passport/src/Token.php
httpdocs/vendor/laravel/passport/src/TokenRepository.php
Repeat in Contact User Model
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;
Go to console enter
php artisan passport:install

@mohammad-69 @armashfankar @SanderSander
@uriel2707 thank you.
Your solution work for my case. Noted.
We also need to apply "use CrudTrait;" in each model as well.
Check your code for Correct Order
<?php
namespace App;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
@uriel2707 Thanks, your solution works.
However, editing gitignored files is not a correct solution. Every time someone clones the project or pulls this change, he will need to manually edit files. This is a temporary solution, a correct solution should be implemented into laravel-mongodb repository.
I have working solution based on @uriel2707 answers but without editing ignored files inside _vendors_ directory.
I have modified _/app/User.php_ file.
```
namespace App;
use IlluminateNotificationsNotifiable;
use IlluminateAuthAuthenticatable;
use IlluminateAuthPasswordsCanResetPassword;
use IlluminateFoundationAuthAccessAuthorizable;
use IlluminateContractsAuthAuthenticatable as AuthenticatableContract;
use IlluminateContractsAuthAccessAuthorizable as AuthorizableContract;
use IlluminateContractsAuthCanResetPassword as CanResetPasswordContract;
use JenssegersMongodbEloquentModel as Model;
class UserAuthenticatable extends Model implements
AuthenticatableContract,
AuthorizableContract,
CanResetPasswordContract
{
use Authenticatable, Authorizable, CanResetPassword;
}
class User extends UserAuthenticatable
{
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}
```
Hope this will help :)
hello
i've the same problem and this is working for me.
on app/User.php
change this
use Illuminate\Foundation\Auth\User as Authenticatable;
to
use Jenssegers\Mongodb\Auth\User as Authenticatable;
Call to a member function getDateFormat() on null
After installation laravel-mongodb run command for composer
php artisan clear-compiled and composer dump-autoload => for composer global installation
This is fixed with https://github.com/jenssegers/laravel-mongodb/pull/1333
Most helpful comment
hello
i've the same problem and this is working for me.
on app/User.php
change this
use Illuminate\Foundation\Auth\User as Authenticatable;to
use Jenssegers\Mongodb\Auth\User as Authenticatable;