我正在开发Laravel 5.5中的Mongo DB应用程序 . 但是在包https://github.com/jenssegers/laravel-mongodb中收到以下错误 .
Jenssegers \ Mongodb \ Eloquent \ HybridRelations :: belongsToMany($ related,$ collection = NULL,$ foreignKey = NULL,$ otherKey = NULL,$ relation = NULL)的声明应与Illuminate \ Database \ Eloquent \ Model ::兼容belongsToMany($ related,$ table = NULL,$ foreignPivotKey = NULL,$ relatedPivotKey = NULL,$ parentKey = NULL,$ relatedKey = NULL,$ relation = NULL)
以下是我做的步骤 .
-
已安装Mongo db及其php扩展 .
-
安装了这个Laravel包 .
-
添加了服务提供商
-
已配置的数据库
-
创建了模型
-
最后
$user = DB::connection('mongodb')->collection('users')->get();
3 回答
据我所知,Laravel 5.5已经改变了
belongsToMany
方法的签名,所以你应该等到这个包与Laravel 5.5兼容我看到这个问题已经在这里创建了:https://github.com/jenssegers/laravel-mongodb/issues/1279现在已修复 . 请检查file . 使用此修复程序覆盖本地文件解决了该问题 .
今天发布了一个版本,支持laravel 5.5,在存储库中运行更新 .
在作曲家使用版本3.3
"jenssegers/mongodb": "3.3.*"