Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 如何在Lighthouse php中编写此查询-&燃气轮机;博客:where(';status';1)&>;其中(';title';、';like';、';%';$术语)&>;分页(6)_Laravel_Vue.js_Graphql_Lighthouse_Laravel Lighthouse - Fatal编程技术网

Laravel 如何在Lighthouse php中编写此查询-&燃气轮机;博客:where(';status';1)&>;其中(';title';、';like';、';%';$术语)&>;分页(6)

Laravel 如何在Lighthouse php中编写此查询-&燃气轮机;博客:where(';status';1)&>;其中(';title';、';like';、';%';$术语)&>;分页(6),laravel,vue.js,graphql,lighthouse,laravel-lighthouse,Laravel,Vue.js,Graphql,Lighthouse,Laravel Lighthouse,我在我的Laravel项目中使用如下查询获取数据: -> Blog::where('status', 1)->where('title', 'like', '%'.$term.'%')->paginate(6); 现在我正在使用Laravel+Lighthouse php作为我的后端API 如何在Lighthouse PHP中编写此查询?您可以在模型中使用雄辩的范围来确定您的状态条件: public function scopeEnabledBlogs($query) {

我在我的
Laravel
项目中使用如下查询获取数据:

-> Blog::where('status', 1)->where('title', 'like', '%'.$term.'%')->paginate(6);
现在我正在使用
Laravel+Lighthouse php
作为我的后端API


如何在Lighthouse PHP中编写此查询?

您可以在模型中使用雄辩的范围来确定您的状态条件:

public function scopeEnabledBlogs($query) {
    return $query->where('status', 1);
}
在您的模式中使用:

extend type Query {
    Blogs(title: String @where(operator: "like")): [Blog!] @paginate(scopes: ["enabledBlogs"])
}
现在,您可以查询您的博客,如:

query {
    Blogs(first: 6 title: "%something%") {
        data {
            title
        }
    }
}