$row) { $arr['key'] = $key; $arr['value'] = $row; $arr['click_index'] = false; array_push($data, $arr); } return $data; } return []; } protected static function init() { self::afterInsert(function ($row) { $pk = $row->getPk(); $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]); }); } public function getKindList() { return ['SINGLE' => __('Kind single'), 'MULTI' => __('Kind multi')]; } public function getStatusList() { return ['1' => __('Status 1'), '0' => __('Status 0')]; } public function getKindTextAttr($value, $data) { $value = $value ? $value : (isset($data['kind']) ? $data['kind'] : ''); $list = $this->getKindList(); 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 paper() { return $this->belongsTo('app\admin\model\Servicepaper', 'paper_id', 'id', [], 'LEFT')->setEagerlyType(0); } }