RoomSignupModel.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace app\admin\model\exam;
  3. use addons\exam\model\BaseModel;
  4. use app\admin\model\User;
  5. class RoomSignupModel extends BaseModel
  6. {
  7. // 表名
  8. protected $name = 'exam_room_signup';
  9. // 自动写入时间戳字段
  10. protected $autoWriteTimestamp = 'int';
  11. // 定义时间戳字段名
  12. protected $createTime = 'createtime';
  13. protected $updateTime = 'updatetime';
  14. protected $deleteTime = false;
  15. // 追加属性
  16. protected $append = [
  17. 'status_text'
  18. ];
  19. public function getStatusList()
  20. {
  21. return [
  22. '0' => '待审核',
  23. '1' => '报名成功',
  24. '2' => '报名被拒绝',
  25. ];
  26. // return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2')];
  27. }
  28. public function getStatusTextAttr($value, $data)
  29. {
  30. $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
  31. $list = $this->getStatusList();
  32. return isset($list[$value]) ? $list[$value] : '';
  33. }
  34. public function room()
  35. {
  36. return $this->belongsTo(RoomModel::class, 'room_id', 'id', [], 'LEFT')->setEagerlyType(0);
  37. }
  38. public function user()
  39. {
  40. return $this->belongsTo(User::class, 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
  41. }
  42. }