__('Sex 1'), '2' => __('Sex 2')]; } public function getStatusList() { return ['1' => __('Status 1'), '0' => __('Status 0')]; } public function getSexTextAttr($value, $data) { $value = $value ? $value : (isset($data['sex']) ? $data['sex'] : ''); $list = $this->getSexList(); return isset($list[$value]) ? $list[$value] : ''; } public function getGetToTimeTextAttr($value, $data) { $value = $value ? $value : (isset($data['get_to_time']) ? $data['get_to_time'] : ''); return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $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 getCreateTimeTextAttr($value, $data) { $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : ''); return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; } public function getUpdateTimeTextAttr($value, $data) { $value = $value ? $value : (isset($data['update_time']) ? $data['update_time'] : ''); return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; } protected function setGetToTimeAttr($value) { return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); } protected function setCreateTimeAttr($value) { return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); } protected function setUpdateTimeAttr($value) { return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); } public function user() { return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0); } public function canteen() { return $this->belongsTo('app\admin\model\hotel\Canteen', 'canteen_id', 'id', [], 'LEFT')->setEagerlyType(0); } public function room() { return $this->belongsTo('app\admin\model\hotel\canteen\Room', 'canteen_id', 'id', [], 'LEFT')->setEagerlyType(0); } }