__('Is_leader 0'), '1' => __('Is_leader 1')]; } public function getStatusList() { return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2'), '3' => __('Status 3')]; } public function getIsLeaderTextAttr($value, $data) { $value = $value ? $value : (isset($data['is_leader']) ? $data['is_leader'] : ''); $list = $this->getIsLeaderList(); return isset($list[$value]) ? $list[$value] : ''; } public function getStarttimeTextAttr($value, $data) { $value = $value ? $value : (isset($data['starttime']) ? $data['starttime'] : ''); return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; } public function getEndtimeTextAttr($value, $data) { $value = $value ? $value : (isset($data['endtime']) ? $data['endtime'] : ''); 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] : ''; } protected function setStarttimeAttr($value) { return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); } protected function setEndtimeAttr($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 game() { return $this->belongsTo('Game', 'game_id', 'id', [], 'LEFT')->setEagerlyType(0); } public function place() { return $this->belongsTo('Gameplace', 'game_place_id', 'id', [], 'LEFT')->setEagerlyType(0); } }