在我的用户控制器的索引中,我有以下内容:
return QueryBuilder::for(User::class)
->with('phoneNumbers')
->allowedIncludes('trashed')
->get();
我希望通过这样的包含参数:
http://127.0.0.1:8000/v1/users?include=trashed
要将 withTrashed()
全局范围附加到查询 .
这可能吗?我很可能遗漏了一些明显的东西,我在测试中尝试了一些变化,通常最终会出现如下错误:
"message": "Call to a member function addEagerConstraints() on boolean",
"exception": "Symfony\\Component\\Debug\\Exception\\FatalThrowableError",
"file": "/Users/timwickstrom/Sites/Wavefire/api/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php",
"line": 522,
供参考:https://github.com/spatie/laravel-query-builder enter link description here
1 回答
看完那个图书馆后,这就是我所拥有的 .