PersonInterviewController.php 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <?php
  2. namespace App\Admin\Controllers\Person;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\CompanyInterView;
  5. use App\Models\Subsite;
  6. use Encore\Admin\Controllers\HasResourceActions;
  7. use Encore\Admin\Facades\Admin;
  8. use Encore\Admin\Form;
  9. use Encore\Admin\Grid;
  10. use Encore\Admin\Layout\Content;
  11. use Encore\Admin\Show;
  12. class PersonInterviewController 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. return $content
  24. ->header('面试邀请')
  25. ->description('列表')
  26. ->body($this->grid());
  27. }
  28. /**
  29. * Show interface.
  30. *
  31. * @param mixed $id
  32. * @param Content $content
  33. * @return Content
  34. */
  35. public function show($id, Content $content)
  36. {
  37. return $content
  38. ->header('面试邀请')
  39. ->description('详细')
  40. ->body($this->detail($id));
  41. }
  42. /**
  43. * Edit interface.
  44. *
  45. * @param mixed $id
  46. * @param Content $content
  47. * @return Content
  48. */
  49. public function edit($id, Content $content)
  50. {
  51. return $content
  52. ->header('面试邀请')
  53. ->description('编辑')
  54. ->body($this->editForm($id)->edit($id));
  55. }
  56. /**
  57. * Create interface.
  58. *
  59. * @param Content $content
  60. * @return Content
  61. */
  62. public function create(Content $content)
  63. {
  64. return $content
  65. ->header('面试邀请')
  66. ->description('创建')
  67. ->body($this->createForm());
  68. }
  69. /**
  70. * Make a grid builder.
  71. *
  72. * @return Grid
  73. */
  74. protected function grid()
  75. {
  76. $grid = new Grid(new CompanyInterView);
  77. $grid->model()->when(get_subsite_id()>0, function ($query) {
  78. $query->whereHas('resumes', function ($query) {
  79. $query->where('subsite_id', get_subsite_id());
  80. });
  81. })->orderBy('id', 'desc');
  82. $grid->id('ID');
  83. $grid->jobs_name('职位名称')->width(200);
  84. $grid->company_name('公司名称')->width(200);
  85. $grid->resume_name('简历名称')->width(150);
  86. $grid->personal_look('查看状态')->display(function ($personal_look) {
  87. switch ($personal_look) {
  88. case 1:
  89. $personal_look = '未查看';
  90. break;
  91. case 2:
  92. $personal_look = '已查看';
  93. break;
  94. default:
  95. $personal_look = '未查看';
  96. break;
  97. }
  98. return $personal_look;
  99. });
  100. $grid->interview_time('邀请时间')->display(function ($interview_time) {
  101. return date('Y-m-d H:i:s', $interview_time);
  102. })->sortable();
  103. $grid->column('members.subsite_id', '所属分站')->display(function ($subsite_id) {
  104. if ($subsite_id) {
  105. $Subsite = Subsite::find($subsite_id);
  106. return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
  107. }
  108. return '总站';
  109. })->width(150);
  110. $grid->created_at('申请时间')->sortable();
  111. $grid->updated_at('更新时间')->sortable();
  112. $grid->actions(function ($actions) use ($grid) {
  113. if (Admin::user()->can('person_apply_jobs_delete')) {
  114. $actions->disableDelete(false);
  115. }
  116. });
  117. if (Admin::user()->can('person_apply_jobs_delete')) {
  118. $grid->tools(function ($tools) {
  119. $tools->batch(function ($batch) {
  120. $batch->disableDelete(false);
  121. });
  122. });
  123. $grid->disableRowSelector(false);
  124. }
  125. $grid->filter(function ($filter) {
  126. $filter->disableIdFilter();
  127. $filter->where(function ($query) {
  128. switch ($this->input) {
  129. case 1:
  130. $query->whereRaw(" personal_look =".$this->input);
  131. break;
  132. case 2:
  133. $query->whereRaw(" personal_look =".$this->input);
  134. break;
  135. }
  136. }, '查看状态', 'look')->select([
  137. 1=>'未查看',
  138. 2=>'已查看',
  139. ]);
  140. $filter->where(function ($query) {
  141. switch ($this->input) {
  142. case 3:
  143. $date = date('Y-m-d H:i:s', strtotime('-3 day'));
  144. $query->whereRaw(" created_at >='".$date."'");
  145. break;
  146. case 7:
  147. $date = date('Y-m-d H:i:s', strtotime('-7 day'));
  148. $query->whereRaw(" created_at >='".$date."'");
  149. break;
  150. case 30:
  151. $date = date('Y-m-d H:i:s', strtotime('-30 day'));
  152. $query->whereRaw(" created_at >='".$date."'");
  153. break;
  154. case 180:
  155. $date = date('Y-m-d H:i:s', strtotime('-180 day'));
  156. $query->whereRaw(" created_at >='".$date."'");
  157. break;
  158. case 365:
  159. $date = date('Y-m-d H:i:s', strtotime('-365 day'));
  160. $query->whereRaw(" created_at >='".$date."'");
  161. break;
  162. }
  163. }, '时间范围', 'apply')->select([
  164. 3=>'三天内',
  165. 7=>'一周内',
  166. 30=>'一月内',
  167. 180=>'半年内',
  168. 365=>'一年内',
  169. ]);
  170. $filter->like('company_name', '公司名称');
  171. $filter->like('resume_name', '简历名称 ');
  172. $filter->equal('members.subsite_id', '所属分站')->select(array_column(get_all_subsite(), 'sitename', 'id'));
  173. });
  174. return $grid;
  175. }
  176. /**
  177. * Make a show builder.
  178. *
  179. * @param mixed $id
  180. * @return Show
  181. */
  182. protected function detail($id)
  183. {
  184. $show = new Show(CompanyInterView::findOrFail($id));
  185. $show->id('ID');
  186. $show->jobs_name('职位名称');
  187. $show->company_name('公司名称');
  188. $show->resume_name('简历名称');
  189. $show->personal_look('查看状态')->as(function ($personal_look) {
  190. switch ($personal_look) {
  191. case 1:
  192. $personal_look = '未查看';
  193. break;
  194. case 2:
  195. $personal_look = '已查看';
  196. break;
  197. default:
  198. $personal_look = '未查看';
  199. break;
  200. }
  201. return $personal_look;
  202. });
  203. $show->interview_time('邀请时间')->as(function ($interview_time) {
  204. return date('Y-m-d H:i:s', $interview_time);
  205. })->sortable();
  206. $show->members('所属分站')->as(function ($members) {
  207. if ($members->subsite_id) {
  208. $Subsite = Subsite::find($members->subsite_id);
  209. return isset($Subsite->sitename) ? $Subsite->sitename : '未知';
  210. }
  211. return '总站';
  212. });
  213. $show->created_at('添加时间');
  214. $show->updated_at('更新时间');
  215. return $show;
  216. }
  217. /**
  218. * Make a form builder.
  219. *
  220. * @return Form
  221. */
  222. protected function form()
  223. {
  224. $form = new Form(new CompanyInterView);
  225. $form->display('id');
  226. $form->display('created_at');
  227. $form->display('updated_at');
  228. return $form;
  229. }
  230. /**
  231. * Make a form builder.
  232. *
  233. * @return Form
  234. */
  235. protected function editForm($id)
  236. {
  237. $form = new Form(new CompanyInterView);
  238. $form->setAction(route('admin.personal.addPoints'));
  239. $MembersHandsel = MembersHandsel::findOrFail($id);
  240. $utype = $MembersHandsel->utype;
  241. $points = MembersHandsel::find($id)->membersPoints()->where('utype', $utype)->first();
  242. $form->display('points_num', '会员积分')->with(function () use ($points) {
  243. return $points->points;
  244. });
  245. $form->radio('points_type', '操作积分')->options([1 => '增加', 2=> '减少'])->default(1);
  246. $form->number('many_point', '增减积分')->default(0)->min(0);
  247. $form->text('explain', '操作说明');
  248. $form->switch('ismany', '是否收费?');
  249. $form->number('amount', '收费金额')->default(0)->min(0);
  250. $form->hidden('points_id')->default($points->id);
  251. $form->footer(function ($footer) {
  252. // 去掉`重置`按钮
  253. $footer->disableReset();
  254. // 去掉`查看`checkbox
  255. $footer->disableViewCheck();
  256. // 去掉`继续编辑`checkbox
  257. $footer->disableEditingCheck();
  258. // 去掉`继续创建`checkbox
  259. $footer->disableCreatingCheck();
  260. });
  261. $form->tools(function (Form\Tools $tools) {
  262. // 去掉`删除`按钮
  263. $tools->disableDelete();
  264. });
  265. return $form;
  266. }
  267. protected function createForm()
  268. {
  269. $form = new Form(new CompanyInterView);
  270. $form->display('id');
  271. $form->display('created_at');
  272. $form->display('updated_at');
  273. return $form;
  274. }
  275. /**
  276. * Store a newly created resource in storage.
  277. *
  278. * @return mixed
  279. */
  280. public function store()
  281. {
  282. return $this->createForm()->store();
  283. }
  284. /**
  285. * Update the specified resource in storage.
  286. *
  287. * @param int $id
  288. *
  289. * @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
  290. */
  291. public function update($id)
  292. {
  293. return $this->editForm()->update($id);
  294. }
  295. }