getPk(); $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]); }); } public function getFlagList() { return ['hot' => __('Flag hot'), 'index' => __('Flag index'), 'recommend' => __('Flag recommend')]; } public function getStatusList() { return ['normal' => __('Normal'), 'hidden' => __('Hidden')]; } public function getFlagTextAttr($value, $data) { $value = $value ? $value : (isset($data['flag']) ? $data['flag'] : ''); $valueArr = explode(',', $value); $list = $this->getFlagList(); return implode(',', array_intersect_key($list, array_flip($valueArr))); } public function getStatusTextAttr($value, $data) { $value = $value ? $value : (isset($data['status']) ? $data['status'] : ''); $list = $this->getStatusList(); return isset($list[$value]) ? $list[$value] : ''; } protected function setFlagAttr($value) { return is_array($value) ? implode(',', $value) : $value; } }