Laravel中pluck的使用——返回指定的字段值信息列表

简介: $model = self::where(['is_delete' => 0, 'is_on_sale' => 1]) ->whereIn('goods.cat_id', GoodsCategory::getCategoryIds($category)) ...
$model = self::where(['is_delete' => 0, 'is_on_sale' => 1])
            ->whereIn('goods.cat_id', GoodsCategory::getCategoryIds($category))
            ->pluck('brand_id');
return self::formatBody(['brands' => $model->toArray()]);

 

学习交流群:364976091
相关文章
|
PHP
Laravel返回不重复的某个字段信息列表
->groupBy('brand_id') ->pluck('brand_id');  学习交流群:364976091
2071 0
|
API
@JsonView 处理返回值,实现接口返回想要的字段
@JsonView 处理返回的json ,实现返回需要的字段
1685 0
更改字段的值
  public class ClassInit { private Person person=new Person("test", "test1"); private Person[] flock =new Person[]{ person }; p...
585 0
|
JSON 前端开发 数据格式
根据ID集合查询符合某种类型的用户信息,并按其他类型分类
根据ID集合查询符合某种类型的用户信息,并按其他类型分类
116 0
|
Java
输入源“/body/sub_mchid”映射到字段“子商户号”必填性规则校验失败,此字段为必填项
输入源“/body/sub_mchid”映射到字段“子商户号”必填性规则校验失败,此字段为必填项
881 0
|
JSON 数据格式
fastadmin设置默认返回json类型
fastadmin设置默认返回json类型
569 0
|
JSON 安全 Go
Go 中使用 JSON 时,如何区分空字段和未设置字段
Go 中使用 JSON 时,如何区分空字段和未设置字段
695 0
|
7月前
|
JSON JavaScript 数据格式
Jquery 将 JSON 列表的 某个属性值,添加到数组中,并判断一个值,在不在数据中
Jquery 将 JSON 列表的 某个属性值,添加到数组中,并判断一个值,在不在数据中
106 0