Laravel-mongodb: Call to a member function getDateFormat() on null

Created on 15 Oct 2016  路  12Comments  路  Source: jenssegers/laravel-mongodb

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 :

https://laravel.com/docs/5.3/passport

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 ?

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;

All 12 comments

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?
screenshot from 2017-01-19 15 21 13

@mohammad-69 have you solved this? please let me know the solution.

Error: Class Model Laravel no extens for Class Jenssegers Model

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

imagen

@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;

other solution

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

Its Works

Was this page helpful?
0 / 5 - 0 ratings