Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how use laravel 7 passport with mongodb?

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?

like image 965
SaeedNikmehr Avatar asked Oct 15 '22 03:10

SaeedNikmehr


1 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';
like image 73
Sadeq Avatar answered Oct 19 '22 03:10

Sadeq