with(['bindGoods', 'bindTemplate']) ->where($map)->order('sort desc,id desc')->select()->toArray(); } /** * 关联产品数据 * @return HasOne */ public function goods(): HasOne { return $this->hasOne(PluginWemallGoodsItem::class, 'ghash', 'ghash')->with('bindGoods'); } /** * 绑定产品数据 * @return HasOne */ public function bindGoods(): HasOne { return $this->goods()->bind([ 'gcode' => 'gcode', 'gname' => 'gname', 'gunit' => 'gunit', 'gspec' => 'gspec', 'gcover' => 'gcover', ]); } /** * 关联模板数据 * @return \think\model\relation\HasOne */ public function template(): HasOne { return $this->hasOne(PluginWumaSourceTemplate::class, 'code', 'tcode')->where(['deleted' => 0]); } /** * 绑定模板数据 * @return HasOne */ public function bindTemplate(): HasOne { return $this->template()->bind([ 'tname' => 'name', 'tstatus' => 'status', 'sdeleted' => 'deleted' ]); } }