how use laravel 7 passport with mongodb?

Viewed 1475

I installed jenssegers/laravel package to use mongodb in my Laravel project, but when I try to install passport I get this error :

Call to a member function prepare() on null

Call to a member function prepare() on null

I tried to use designmynight package, but it seems it is not compatible with jenssegers v4 that I use for Laravel 7 .

Any idea how to fix this problem?

2 Answers

It's Very Simple.Without any extra package it's possible.

Only edit AuthCode.php,PersonalAccessClient.php,Client.php and Token.php in this path:

"/vendor/laravel/passport/src/"

replace this line:

use Jenssegers\Mongodb\Eloquent\Model;

by this line:

use Illuminate\Database\Eloquent\Model;

Notice:if you use multi connection specific your mongo connection in all of top Model,like this:

protected $connection = 'mongodb';

Currently I'm using Laravel 8 with Jessengers V4 and I had the same issue

Inside vendor of passport just replace with:

use Jenssegers\Mongodb\Eloquent\Model

Instead

   use Illuminate\Database\Eloquent\Model;

Everything works properly. I recommend write a script which automatically replace, maybe using command "sed" or fork the project.

Related