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
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?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.