首页 > 解决方案 > laravel mongodb 在 null 上调用成员函数 prepare()

问题描述

我想保存数据时出错。

该错误仅发生在VPS 服务器上,当我在localhost上运行它时,它工作正常。

我的脚本:

$rating = new \willvincent\Rateable\Rating;
$rating->rating = $request->rate;
$rating->rateable_id = $request->id;
$rating->rateable_type = 'App\Product';
$rating->user_id = auth()->user()->id;
$rating->title = $request->title;
$rating->detail = $request->detail;
$rating->save();

所有数据填写正确,只有进入$rating->save();流程才会出现错误。

错误信息:

"message": "Call to a member function prepare() on null",
"exception": "Symfony\\Component\\Debug\\Exception\\FatalThrowableError",
"file": "/home/krabs/public_html/pricesm.com/vendor/laravel/framework/src/Illuminate/Database/Connection.php",
"line": 452,

问题是修复:

标签: laravelmongodb

解决方案


推荐阅读