多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
## 1.关联加入select指定字段 ``` public function CustomerInfo() { return $this->belongsTo(CustomerInfo::class, 'customer_id', 'id')->select(['id', 'company_name', 'company_code', 'external_code', 'credit_total', 'customer_level', 'customer_state', 'goods_state']); } ``` ## 2. 闭包内select指定字段 ``` ActiveJieSuan::with(['user' => function ($query) {$query->select('id','name');}, 'active'=> function ($query) { $query->select('id','name','start'); } ]) ->paginate()->toArray(); ``` ## 3.简便写法 ``` ActiveJieSuan::with(['user:id,name','active:id,name,start']) ->paginate() ->toArray(); ```