Zibon Badi
Zibon Badi

Reputation: 1

Query Builder receiving MySqlConnection for `jenssegers/laravel-mongodb` using Laravel 8

I am having trouble setting up a MongoDB-based Laravel 8 app using jenssegers/laravel-mongodb. After setting up the necessary resource controllers, routes and models, calling any of the API routes results in the following error:

Jenssegers\Mongodb\Query\Builder::__construct(): Argument #1 ($connection) must be of type Jenssegers\Mongodb\Connection, Illuminate\Database\MySqlConnection given, called in <\path\to\vendor\jenssegers\mongodb\src\Eloquent\Model.php>

I assume the system is applying a default SQL connection due to some missing configuration, however all help resources I found were out of date. My local .env contains the additional lines below, but is otherwise untouched from the default example. Changing DB_CONNECTION= to mongodb did not change anything during troubleshooting:

MONGO_DB_HOST=127.0.0.1
MONGO_DB_PORT=27017
MONGO_DB_DATABASE=database
MONGO_DB_USERNAME=
MONGO_DB_PASSWORD=

Furthermore, the beginning of the model class in question looks like this:

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Jenssegers\Mongodb\Eloquent\Model;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;

Hopefully you can help me find the missing . Thanks in advance.

Upvotes: 0

Views: 426

Answers (0)

Related Questions