123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <?php
- namespace app\admin\model\party;
- use think\Model;
- class Party extends Model
- {
-
-
- // 表名
- protected $name = 'party';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'is_cool_text',
- 'room_type_text',
- 'is_online_text',
- 'status_text',
- 'is_recommend_text',
- 'is_screen_text',
- 'on_model_text'
- ];
- public function getIsCoolList()
- {
- return ['0' => __('Is_cool 0'), '1' => __('Is_cool 1')];
- }
- public function getRoomTypeList()
- {
- return ['1' => __('Room_type 1'), '2' => __('Room_type 2')];
- }
- public function getIsOnlineList()
- {
- return ['1' => __('Is_online 1'), '0' => __('Is_online 0')];
- }
- public function getStatusList()
- {
- return ['-1' => __('Status -1'), '1' => __('Status 1')];
- }
- public function getIsRecommendList()
- {
- return ['1' => __('Is_recommend 1'), '0' => __('Is_recommend 0')];
- }
- public function getIsCloseList()
- {
- return ['1' => __('Is_close 1'), '0' => __('Is_close 0')];
- }
- public function getIsScreenList()
- {
- return ['1' => __('Is_screen 1'), '0' => __('Is_screen 0')];
- }
- public function getOnModelList()
- {
- return ['1' => __('On_model 1'), '2' => __('On_model 2')];
- }
- public function getIsCoolTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['is_cool']) ? $data['is_cool'] : '');
- $list = $this->getIsCoolList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getRoomTypeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['room_type']) ? $data['room_type'] : '');
- $list = $this->getRoomTypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getIsOnlineTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['is_online']) ? $data['is_online'] : '');
- $list = $this->getIsOnlineList();
- 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 getIsRecommendTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['is_recommend']) ? $data['is_recommend'] : '');
- $list = $this->getIsRecommendList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getIsScreenTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['is_screen']) ? $data['is_screen'] : '');
- $list = $this->getIsScreenList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getOnModelTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['on_model']) ? $data['on_model'] : '');
- $list = $this->getOnModelList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function user()
- {
- return $this->belongsTo('app\admin\model\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- //关联派对类型表
- public function partyType()
- {
- return $this->hasOne(Type::class, 'id', 'party_type',[],'LEFT');
- }
- }
|