getPk(); $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]); } }); } public function getTypeList() { return ['1' => __('Type 1'), '2' => __('Type 2')]; } public function getRecommendList() { return ['0' => __('Recommend 0'), '1' => __('Recommend 1')]; } public function getHotList() { return ['0' => __('Hot 0'), '1' => __('Hot 1')]; } public function getFineList() { return ['0' => __('Fine 0'), '1' => __('Fine 1')]; } public function getTypeTextAttr($value, $data) { $value = $value ?: ($data['type'] ?? ''); $list = $this->getTypeList(); return $list[$value] ?? ''; } public function getRecommendTextAttr($value, $data) { $value = $value ?: ($data['recommend'] ?? ''); $list = $this->getRecommendList(); return $list[$value] ?? ''; } public function getHotTextAttr($value, $data) { $value = $value ?: ($data['hot'] ?? ''); $list = $this->getHotList(); return $list[$value] ?? ''; } public function getFineTextAttr($value, $data) { $value = $value ?: ($data['fine'] ?? ''); $list = $this->getFineList(); return $list[$value] ?? ''; } public function getReleaseTimeTextAttr($value, $data) { $value = $value ?: ($data['release_time'] ?? ''); return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; } protected function setReleaseTimeAttr($value) { return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); } public function cate() { return $this->belongsTo('app\admin\model\news\Cate', 'cate_id', 'id', [], 'LEFT')->setEagerlyType(0); } }