column('name'); return implode(',',$classes_cate_title); } public function getClassesLabelTitleAttr($value, $data) { $classes_cate_ids = (isset($data['classes_label_ids']) ? $data['classes_label_ids'] : ''); if(!$classes_cate_ids) return ''; //$classes_cate_ids 查询分类表 names 已逗号拼接返回 $classes_cate_title = Label::where('id','in',$classes_cate_ids)->column('name'); return implode(',',$classes_cate_title); } protected static function init() { self::afterInsert(function ($row) { if (!$row['weigh']) { $pk = $row->getPk(); $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]); } }); } public function getAddTypeList() { return ['1' => __('Add_type 1'), '2' => __('Add_type 2')]; } public function getTypeList() { return ['out' => __('Type out'), 'in' => __('Type in')]; } public function getAddressTypeList() { return ['1' => __('Address_type 1'), '2' => __('Address_type 2')]; } public function getStatusList() { return ['1' => __('Status 1'), '2' => __('Status 2'), '3' => __('Status 3')]; } public function getAuthStatusList() { return ['0' => __('Auth_status 0'), '1' => __('Auth_status 1'), '2' => __('Auth_status 2')]; } public function getRecommendList() { return ['0' => __('Recommend 0'), '1' => __('Recommend 1')]; } public function getHotList() { return ['0' => __('Hot 0'), '1' => __('Hot 1')]; } public function getNewList() { return ['0' => __('New 0'), '1' => __('New 1')]; } public function getSelfhotList() { return ['0' => __('Selfhot 0'), '1' => __('Selfhot 1')]; } public function getAddTypeTextAttr($value, $data) { $value = $value ? $value : (isset($data['add_type']) ? $data['add_type'] : ''); $list = $this->getAddTypeList(); return isset($list[$value]) ? $list[$value] : ''; } public function getTypeTextAttr($value, $data) { $value = $value ? $value : (isset($data['type']) ? $data['type'] : ''); $list = $this->getTypeList(); return isset($list[$value]) ? $list[$value] : ''; } public function getAddressTypeTextAttr($value, $data) { $value = $value ? $value : (isset($data['address_type']) ? $data['address_type'] : ''); $list = $this->getAddressTypeList(); return isset($list[$value]) ? $list[$value] : ''; } public function getStatusTextAttr($value, $data) { $value = $value ? $value : (isset($data['status']) ? $data['status'] : ''); $list = $this->getStatusList(); return isset($list[$value]) ? $list[$value] : ''; } public function getAuthStatusTextAttr($value, $data) { $value = $value ? $value : (isset($data['auth_status']) ? $data['auth_status'] : ''); $list = $this->getAuthStatusList(); return isset($list[$value]) ? $list[$value] : ''; } public function getAuthTimeTextAttr($value, $data) { $value = $value ? $value : (isset($data['auth_time']) ? $data['auth_time'] : ''); return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; } public function getRecommendTextAttr($value, $data) { $value = $value ? $value : (isset($data['recommend']) ? $data['recommend'] : ''); $list = $this->getRecommendList(); return isset($list[$value]) ? $list[$value] : ''; } public function getHotTextAttr($value, $data) { $value = $value ? $value : (isset($data['hot']) ? $data['hot'] : ''); $list = $this->getHotList(); return isset($list[$value]) ? $list[$value] : ''; } public function getNewTextAttr($value, $data) { $value = $value ? $value : (isset($data['new']) ? $data['new'] : ''); $list = $this->getNewList(); return isset($list[$value]) ? $list[$value] : ''; } public function getSelfhotTextAttr($value, $data) { $value = $value ? $value : (isset($data['selfhot']) ? $data['selfhot'] : ''); $list = $this->getSelfhotList(); return isset($list[$value]) ? $list[$value] : ''; } protected function setAuthTimeAttr($value) { return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); } public function manystore() { return $this->belongsTo(Manystore::class, 'manystore_id', 'id', [], 'LEFT')->setEagerlyType(0); } public function shop() { return $this->belongsTo('app\admin\model\manystore\Shop', 'shop_id', 'id', [], 'LEFT')->setEagerlyType(0); } public function user() { return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0); } public function admin() { return $this->belongsTo('app\admin\model\Admin', 'admin_id', 'id', [], 'LEFT')->setEagerlyType(0); } }