JobSubscribeController.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <?php
  2. namespace App\Admin\Controllers\Person;
  3. /*use App\Models\JobSubscribe;*/
  4. use App\Http\Controllers\Controller;
  5. use App\Models\MemberInfo;
  6. use App\Models\PersonJobsSubscribe;
  7. use Encore\Admin\Controllers\HasResourceActions;
  8. use Encore\Admin\Facades\Admin;
  9. use Encore\Admin\Form;
  10. use Encore\Admin\Grid;
  11. use Encore\Admin\Layout\Content;
  12. use Encore\Admin\Show;
  13. /*use Encore\Admin\Grid;*/
  14. class JobSubscribeController extends Controller
  15. {
  16. use HasResourceActions;
  17. /**
  18. * Index interface.
  19. *
  20. * @param Content $content
  21. * @return Content
  22. */
  23. public function index(Content $content)
  24. {
  25. return $content
  26. ->header('职位订阅')
  27. ->description(' ')
  28. ->body($this->grid());
  29. }
  30. /**
  31. * Show interface.
  32. *
  33. * @param mixed $id
  34. * @param Content $content
  35. * @return Content
  36. */
  37. public function show($id, Content $content)
  38. {
  39. return $content
  40. ->header('Detail')
  41. ->description('description')
  42. ->body($this->detail($id));
  43. }
  44. /**
  45. * Edit interface.
  46. *
  47. * @param mixed $id
  48. * @param Content $content
  49. * @return Content
  50. */
  51. public function edit($id, Content $content)
  52. {
  53. return $content
  54. ->header('Edit')
  55. ->description('description')
  56. ->body($this->form()->edit($id));
  57. }
  58. /**
  59. * Create interface.
  60. *
  61. * @param Content $content
  62. * @return Content
  63. */
  64. public function create(Content $content)
  65. {
  66. return $content
  67. ->header('Create')
  68. ->description('description')
  69. ->body($this->form());
  70. }
  71. /**
  72. * Make a grid builder.
  73. *
  74. * @return Grid
  75. */
  76. protected function grid()
  77. {
  78. $grid = new Grid(new PersonJobsSubscribe);
  79. $grid->model()->orderBy('id','desc');
  80. $grid->email('接收邮箱')->width(150);
  81. $grid->nature_cn('职位性质')->width(100);
  82. $grid->intention_jobs('意向职位')->width(150);
  83. $grid->trade_cn('意向行业')->width(150);
  84. $grid->wage_cn('意向薪资')->width(100);
  85. $grid->district_cn('意向地区')->width(150);
  86. $grid->created_at('添加时间')->sortable();
  87. $grid->disableExport();
  88. $grid->disableCreateButton();
  89. if (Admin::user()->can('person_subscribe_delete')) {
  90. $grid->tools(function ($tools) {
  91. $tools->batch(function ($batch) {
  92. $batch->disableDelete(false);
  93. });
  94. });
  95. }
  96. $grid->actions(function ($actions) {
  97. if (Admin::user()->can('person_subscribe_delete')) {
  98. $actions->disableDelete(false);
  99. }
  100. });
  101. $grid->filter(function ($filter) {
  102. $filter->disableIdFilter();
  103. /*$subsites = array(''=>'不限','0'=>'总站', '1' => '定海', '2' => '普陀');
  104. $filter->equal('subsite_id', '所属分站')->select($subsites);*/
  105. $filter->like('intention_jobs', '意向职位');
  106. $filter->like('trade_cn', '意向行业');
  107. $filter->like('district_cn', '意向地区');
  108. $filter->like('email', '接收邮件');
  109. $date3 = date('Y-m-d', strtotime("-3 day"));
  110. $date7 = date('Y-m-d', strtotime("-7 day"));
  111. $date30 = date("Y-m-d", strtotime("-1 month"));
  112. $date180 = date("Y-m-d", strtotime("-6 month"));
  113. $date360 = date("Y-m-d", strtotime("-1 year"));
  114. $date_option = array(
  115. '' => '不限',
  116. $date3 => '三天内',
  117. $date7 => '一周内',
  118. $date30 => '一月内',
  119. $date180 => '半年内',
  120. $date360 => '一年内',
  121. );
  122. $filter->where(function ($query) {
  123. $query->where('created_at', '>=', "{$this->input}");
  124. }, '添加时间', 'created_at')->radio($date_option);
  125. });
  126. return $grid;
  127. }
  128. /**
  129. * Make a show builder.
  130. *
  131. * @param mixed $id
  132. * @return Show
  133. */
  134. protected function detail($id)
  135. {
  136. $show = new Show(PersonJobsSubscribe::findOrFail($id));
  137. $show->id('ID');
  138. $show->uid('订阅用户')->as(function ($uid) {
  139. $memberInfo = MemberInfo::where(['uid'=>$uid])->first();
  140. if ($memberInfo) {
  141. return $memberInfo->realname;
  142. }
  143. return '';
  144. });
  145. $show->title('订阅名称');
  146. $show->trade_cn('行业分类');
  147. $show->district_cn('工作地区');
  148. $show->intention_jobs('职能分类');
  149. $show->sendTime_cn('发布日期');
  150. $show->experience_cn('工作经验');
  151. $show->wage_cn('薪资范围');
  152. $show->education_cn('学历要求');
  153. $show->rate_cn('接收频率');
  154. $show->send_jobs_cn('发布职位数');
  155. $show->nature_cn('职位性质');
  156. $show->email('接收邮箱');
  157. $show->created_at('添加时间');
  158. $show->updated_at('更新时间');
  159. $show->panel()->tools(function ($tools) {
  160. $tools->disableEdit();
  161. $tools->disableDelete();
  162. });
  163. return $show;
  164. }
  165. /**
  166. * Make a form builder.
  167. *
  168. * @return Form
  169. */
  170. protected function form()
  171. {
  172. $form = new Form(new PersonJobsSubscribe);
  173. $form->display('ID');
  174. $form->display('Created at');
  175. $form->display('Updated at');
  176. return $form;
  177. }
  178. }