hasOne(PluginWemallGoodsItem::class, 'ghash', 'ghash')->with('bindGoods'); } /** * 出库搜索器 * @param mixed $query * @return void */ public function searchOuterAttr($query) { $query->whereIn('type', PluginWumaWarehouseOrder::outerTypes); } /** * 入库搜索器 * @param mixed $query * @return void */ public function searchInterAttr($query) { $query->whereIn('type', PluginWumaWarehouseOrder::interTypes); } /** * 退货搜索器 * @param mixed $query * @return void */ public function searchReturnAttr($query) { $query->whereIn('type', PluginWumaWarehouseOrder::returnTypes); } /** * 绑定产品数据 * @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 warehouse(): HasOne { return $this->hasOne(PluginWumaWarehouse::class, 'code', 'wcode'); } /** * 绑定仓库数据 * @return \think\model\relation\HasOne */ public function bindWarehouse(): HasOne { return $this->warehouse()->bind([ 'wname' => 'name', 'wperson' => 'person', 'wprov' => 'addr_prov', 'wcity' => 'addr_city', 'warea' => 'addr_area', 'wstatus' => 'status', 'wdeleted' => 'deleted' ]); } }