FindJobsController.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\Jobs;
  5. use App\Models\MemberInfo;
  6. use App\Models\Resume;
  7. use Encore\Admin\Controllers\HasResourceActions;
  8. use Encore\Admin\Form;
  9. use Encore\Admin\Grid;
  10. use Encore\Admin\Layout\Content;
  11. use Encore\Admin\Show;
  12. class FindJobsController extends Controller
  13. {
  14. use HasResourceActions;
  15. /**
  16. * Index interface.
  17. *
  18. * @param Content $content
  19. * @return Content
  20. */
  21. public function index(Content $content)
  22. {
  23. $id = request()->id;
  24. $uid = request()->uid;
  25. $resume = Resume::where(['id'=>$id])->first();
  26. $member = MemberInfo::where(['uid'=>$uid])->first();
  27. return $content
  28. ->header('职位匹配')
  29. ->description('列表')
  30. ->body(view('admin.jobs.find_jobs')->with(['grid'=>$this->grid(),'resume'=>$resume,'member'=>$member]));
  31. }
  32. /**
  33. * Show interface.
  34. *
  35. * @param mixed $id
  36. * @param Content $content
  37. * @return Content
  38. */
  39. public function show($id, Content $content)
  40. {
  41. return $content
  42. ->header('职位匹配')
  43. ->description('详细')
  44. ->body($this->detail($id));
  45. }
  46. /**
  47. * Edit interface.
  48. *
  49. * @param mixed $id
  50. * @param Content $content
  51. * @return Content
  52. */
  53. public function edit($id, Content $content)
  54. {
  55. return $content
  56. ->header('职位匹配')
  57. ->description('编辑')
  58. ->body($this->editForm($id)->edit($id));
  59. }
  60. /**
  61. * Create interface.
  62. *
  63. * @param Content $content
  64. * @return Content
  65. */
  66. public function create(Content $content)
  67. {
  68. return $content
  69. ->header('职位匹配')
  70. ->description('创建')
  71. ->body($this->createForm());
  72. }
  73. /**
  74. * Make a grid builder.
  75. *
  76. * @return Grid
  77. */
  78. protected function grid()
  79. {
  80. $grid = new Grid(new Jobs);
  81. $grid->id('ID');
  82. $grid->jobs_name('职位名称');
  83. $grid->company_name('公司名称');
  84. $grid->audit('审核状态')->display(function ($audit) {
  85. switch ($audit) {
  86. case 1:
  87. $audit = '<span style="color: #00a65a;">审核通过</span>';
  88. break;
  89. case 2:
  90. $audit = '<span>审核中</span>';
  91. break;
  92. case 3:
  93. $audit = '<span style="color: red;">审核未通过</span>';
  94. break;
  95. default:
  96. $audit = '<span>审核中</span>';
  97. break;
  98. }
  99. return $audit;
  100. });
  101. $grid->column('categoryScale.demand', '公司规模');
  102. $grid->column('categoryTrade.demand', '所属行业');
  103. $grid->column('categoryEducation.demand', '职位要求');
  104. $grid->column('categoryWage.demand', '薪资待遇');
  105. $grid->created_at('添加时间')->sortable();
  106. $grid->updated_at('更新时间')->sortable();
  107. $grid->disableCreateButton();
  108. $grid->disableExport();
  109. $grid->actions(function ($actions) {
  110. $actions->disableView();
  111. $actions->disableEdit();
  112. });
  113. $grid->tools(function ($tools) {
  114. $but = <<<EOT
  115. <div class="btn-group" data-toggle="buttons">
  116. <label class="btn btn-google btn-sm" id="Apply" title="投递">
  117. <i class="fa fa-audio-description"></i>
  118. <input type="radio" class="user-gender">投递
  119. </label>
  120. </div>
  121. EOT;
  122. $tools->append($but);
  123. });
  124. return $grid;
  125. }
  126. /**
  127. * Make a show builder.
  128. *
  129. * @param mixed $id
  130. * @return Show
  131. */
  132. protected function detail($id)
  133. {
  134. $show = new Show(Jobs::findOrFail($id));
  135. $show->id('ID');
  136. return $show;
  137. }
  138. /**
  139. * Make a form builder.
  140. *
  141. * @return Form
  142. */
  143. protected function editForm($id)
  144. {
  145. $form = new Form(new Jobs);
  146. return $form;
  147. }
  148. protected function createForm()
  149. {
  150. $form = new Form(new Jobs);
  151. return $form;
  152. }
  153. /**
  154. * Store a newly created resource in storage.
  155. *
  156. * @return mixed
  157. */
  158. public function store()
  159. {
  160. return $this->createForm()->store();
  161. }
  162. /**
  163. * Update the specified resource in storage.
  164. *
  165. * @param int $id
  166. *
  167. * @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
  168. */
  169. public function update($id)
  170. {
  171. return $this->editForm($id)->update($id);
  172. }
  173. protected function form()
  174. {
  175. $form = new Form(new Jobs);
  176. $form->display('ID');
  177. $form->display('添加时间');
  178. $form->display('更新时间');
  179. return $form;
  180. }
  181. }