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();
1

3 Answers 3

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

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

-1

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

3 Comments

Until you reinstall your dependencies.
Please override that method on your base model.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.