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
}
}
}