Laravel 5.5 Mongo DB error

2.3k views Asked by At

I am developing a Mongo DB app in Laravel 5.5. But getting following error in the package https://github.com/jenssegers/laravel-mongodb.

Declaration of Jenssegers\Mongodb\Eloquent\HybridRelations::belongsToMany($related, $collection = NULL, $foreignKey = NULL, $otherKey = NULL, $relation = NULL) should be compatible with Illuminate\Database\Eloquent\Model::belongsToMany($related, $table = NULL, $foreignPivotKey = NULL, $relatedPivotKey = NULL, $parentKey = NULL, $relatedKey = NULL, $relation = NULL)

Following are the steps I did.

  1. Installed Mongo db and its php extension.
  2. Installed this Laravel package.
  3. Added the service provider
  4. Configured DB
  5. Created the model
  6. And finally
    $user = DB::connection('mongodb')->collection('users')->get();
3

There are 3 answers

0
Marcin Nabiałek On BEST ANSWER

As far as I know Laravel 5.5 has changed signature of belongsToMany method, so you should wait until this package will be compatible with Laravel 5.5 I see issue about this was already created here: https://github.com/jenssegers/laravel-mongodb/issues/1279

3
Kiren S On

This is fixed now. Please check this file. Overwriting local file with this fix solved the problem.

0
rikardo_paiva On

Today there was a release was released with support for laravel 5.5, run an update in the repository.

In composer use version 3.3 "jenssegers/mongodb": "3.3.*"