我正在使用 laravel-mongodb 库(https://github.com/jenssegers/laravel-mongodb)
当我想创建新记录时,出现此错误:
strlen() expects parameter 1 to be string, array given
在 project.local/vendor/mongodb/mongodb/src/Collection.php:104
这是模型:Category.php
namespace App\Models;
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
class Category extends Eloquent
{
protected $collection = [ 'categories' ];
protected $fillable = [ 'name', 'parentId' ];
}
这是我的商店方法:
public function store(Request $request)
{
// e1: Category::create([ 'name' => 'T-shirts' ]);
$n = new Category;
$n->name = 'T-shirts';
$n->save();
return back();
}