RoomSignup.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace addons\exam\controller;
  3. use addons\exam\model\RoomSignupModel;
  4. /**
  5. * 考场接口
  6. */
  7. class RoomSignup extends Base
  8. {
  9. protected $noNeedLogin = [''];
  10. protected $noNeedRight = ['*'];
  11. protected $user;
  12. /**
  13. * 我的报名记录
  14. */
  15. public function index()
  16. {
  17. $query = RoomSignupModel::with(
  18. [
  19. 'room' => function ($query) {
  20. $query->with(
  21. [
  22. // 'cates' => function ($query) {
  23. // $query->withField('id, name');
  24. // },
  25. 'paper' => function ($query) {
  26. $query->withField('id, title');
  27. },
  28. ]
  29. );//->field('id,name,contents,cate_id,paper_id,');
  30. }
  31. ]
  32. )->where('user_id', $this->auth->id);
  33. // 状态查询
  34. $status = input('status', '');
  35. if (is_numeric($status)) {
  36. $query->where('status', $status);
  37. }
  38. $list = $query->order('id desc')->paginate();
  39. $this->success('', ['list' => $list]);
  40. }
  41. }