2

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();
Kiren S
  • 3,037
  • 7
  • 41
  • 69
  • related: https://stackoverflow.com/questions/50741423/laravel-jensseger-mongodb-belongstomany-returns-empty-array also related: https://stackoverflow.com/questions/46023352/laravel-mongo-many-to-many-relation-wherehas-not-working/53447029 – Traxo Nov 23 '18 at 12:50

3 Answers3

2

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

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
2

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.*"

rikardo_paiva
  • 393
  • 1
  • 5
-1

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

Kiren S
  • 3,037
  • 7
  • 41
  • 69
  • Until you reinstall your dependencies. – nxu Sep 08 '17 at 07:54
  • Please override that method on your base model. – beingjungshahi Sep 13 '17 at 17:27
  • If the fixing of the issue is going and we need that fix in our installed package, it is better to do that in vendor file and continue with our development rather than waiting for the package to be get released. Is there any other idea? Please share it. – Kiren S Oct 27 '17 at 05:57