Recruit.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace app\home\controller;
  3. use app\common\model\RecruitModel;
  4. use app\common\model\RecruitNewsModel;
  5. use app\home\HomeBaseController;
  6. class Recruit extends HomeBaseController
  7. {
  8. protected function init()
  9. {
  10. $this->tab = 'recruit';
  11. }
  12. public function index()
  13. {
  14. $keyword = input('keyword', '');
  15. $limit = 10;
  16. $where = [
  17. ['status', '=', RecruitModel::STATUS_YES],
  18. ['name', 'like', "%$keyword%"],
  19. ];
  20. $total = RecruitModel::where($where)
  21. ->count();
  22. return view('', [
  23. 'keyword' => $keyword,
  24. 'total' => $total,
  25. 'limit' => $limit,
  26. ]);
  27. }
  28. public function list()
  29. {
  30. $page = input('page', 1);
  31. $limit = input('limit', 10);
  32. $keyword = input('keyword', '');
  33. $where = [
  34. ['status', '=', RecruitModel::STATUS_YES],
  35. ];
  36. if (!empty($keyword)) {
  37. $where[] = ['name', 'like', "%$keyword%"];
  38. }
  39. $list = RecruitModel::where($where)
  40. ->page($page, $limit)
  41. ->order(['priority' => 'desc', 'update_time' => 'desc'])
  42. ->append(['current_text','apply_time'])
  43. ->select();
  44. ajax_success($list);
  45. }
  46. public function detail()
  47. {
  48. $id = input('id', 0);
  49. if (empty($id)) {
  50. jump('该招聘不存在或已经删除');
  51. }
  52. $info = RecruitModel::where('status', RecruitModel::STATUS_YES)
  53. ->find($id);
  54. if (empty($info)) {
  55. jump('该招聘不存在或已经删除');
  56. }
  57. return view('', [
  58. 'info' => $info,
  59. ]);
  60. }
  61. }