| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 | 
							- <?php
 
- namespace App\Admin\Controllers\Jobfair;
 
- use App\Http\Controllers\Controller;
 
- use App\Models\Jobfair\JobfairCompany;
 
- use Encore\Admin\Controllers\HasResourceActions;
 
- use Encore\Admin\Facades\Admin;
 
- use Encore\Admin\Form;
 
- use Encore\Admin\Grid;
 
- use Encore\Admin\Layout\Content;
 
- use Encore\Admin\Show;
 
- class JobfairDishonestyController extends Controller
 
- {
 
-     use HasResourceActions;
 
-     /**
 
-      * Index interface.
 
-      *
 
-      * @param Content $content
 
-      * @return Content
 
-      */
 
-     public function index(Content $content)
 
-     {
 
-         return $content
 
-             ->header('不诚信记录')
 
-             ->description('')
 
-             ->body($this->grid());
 
-     }
 
-     /**
 
-      * Show interface.
 
-      *
 
-      * @param mixed $id
 
-      * @param Content $content
 
-      * @return Content
 
-      */
 
-     public function show($id, Content $content)
 
-     {
 
-         return $content
 
-             ->header('不诚信记录详情')
 
-             ->description('')
 
-             ->body($this->detail($id));
 
-     }
 
-     /**
 
-      * Edit interface.
 
-      *
 
-      * @param mixed $id
 
-      * @param Content $content
 
-      * @return Content
 
-      */
 
-     public function edit($id, Content $content)
 
-     {
 
-         return $content
 
-             ->header('不诚信记录编辑')
 
-             ->description('')
 
-             ->body($this->form()->edit($id));
 
-     }
 
-     /**
 
-      * Create interface.
 
-      *
 
-      * @param Content $content
 
-      * @return Content
 
-      */
 
-     public function create(Content $content)
 
-     {
 
-         return $content
 
-             ->header('不诚信记录创建')
 
-             ->description('')
 
-             ->body($this->form());
 
-     }
 
-     /**
 
-      * Make a grid builder.
 
-      *
 
-      * @return Grid
 
-      */
 
-     protected function grid()
 
-     {
 
-         $grid = new Grid(new JobfairCompany);
 
-         $grid->model()->with(['companys','jobfair'])->whereHas('companys')->whereHas('jobfair',function ($query) {
 
-             $query->where('holddate_start','<',strtotime("-30 seconds"));
 
-         })->where('type', '<>', 4)->where('audit',1)
 
- //            ->groupBy('company_id', 'jobfair_id')
 
-             ->orderBy('id', 'desc');
 
-         $grid->column('companys.companyname', '公司名称')->width(200);
 
-         $grid->column('jobfair.title', '招聘会名称')->width(200);
 
-         $grid->column('jobfair.holddate_start', '招聘会开始时间')->display(function ($holddate_start) {
 
-             return date('Y-m-d H:i:s', $holddate_start);
 
-         });
 
-         $grid->column('jobfair.holddate_end', '招聘会结束时间')->display(function ($holddate_end) {
 
-             return date('Y-m-d H:i:s', $holddate_end);
 
-         });
 
-         $grid->type('行为')->display(function ($type) {
 
-             if ($type==0) {
 
-                 return '未签到';
 
-             } elseif ($type==1) {
 
-                 return '迟到';
 
-             } elseif ($type==2) {
 
-                 return '早退';
 
-             } elseif ($type==3) {
 
-                 return '迟到/早退';
 
-             } else {
 
-                 return '未签到';
 
-             }
 
-         });
 
-         $grid->signed_time('签到时间')->display(function ($signed_time) {
 
-             return $signed_time ? date('Y-m-d H:i:s', $signed_time) : '';
 
-         });
 
-         $grid->over_time('注销时间')->display(function ($over_time) {
 
-             return $over_time ? date('Y-m-d H:i:s', $over_time) : '';
 
-         });
 
-         $grid->disableCreateButton();
 
-         $grid->disableExport();
 
-         $grid->actions(function ($actions) use ($grid) {
 
-             if (Admin::user()->can('jobfair_dishonesty_delete')) {
 
-                 $actions->disableDelete(false);
 
-             }
 
-         });
 
-         if (Admin::user()->can('jobfair_dishonesty_delete')) {
 
-             $grid->tools(function ($tools) {
 
-                 $tools->batch(function ($batch) {
 
-                     $batch->disableDelete(false);
 
-                 });
 
-             });
 
-             $grid->disableRowSelector(false);
 
-         }
 
-         $grid->filter(function ($filter) {
 
-             $filter->like('companys.companyname', '公司名称');
 
-             $filter->like('jobfair.title', '招聘会名称');
 
-         });
 
-         return $grid;
 
-     }
 
-     /**
 
-      * Make a show builder.
 
-      *
 
-      * @param mixed $id
 
-      * @return Show
 
-      */
 
-     protected function detail($id)
 
-     {
 
-         $show = new Show(JobfairCompany::findOrFail($id));
 
-         $show->id('ID');
 
-         $show->companys()->companyname('公司名称')->as(function ($companys){
 
-             return $companys->companyname;
 
-         });
 
-         $show->jobfair()->title('招聘会名称')->as(function ($jobfair){
 
-             return $jobfair->title;
 
-         });
 
-         $show->jobfair()->holddate_start('招聘会开始时间')->as(function ($jobfair) {
 
-             return date('Y-m-d H:i:s', $jobfair->holddate_start);
 
-         });
 
-         $show->jobfair()->holddate_end('招聘会结束时间')->as(function ($jobfair) {
 
-             return date('Y-m-d H:i:s', $jobfair->holddate_end);
 
-         });
 
-         $show->type('行为')->as(function ($type) {
 
-             if ($type==0) {
 
-                 return '未签到';
 
-             } elseif ($type==1) {
 
-                 return '迟到';
 
-             } elseif ($type==2) {
 
-                 return '早退';
 
-             } elseif ($type==3) {
 
-                 return '迟到/早退';
 
-             } else {
 
-                 return '未签到';
 
-             }
 
-         });
 
-         $show->signed_time('签到时间')->as(function ($signed_time) {
 
-             return $signed_time ? date('Y-m-d H:i:s', $signed_time) : '';
 
-         });
 
-         $show->over_time('注销时间')->as(function ($over_time) {
 
-             return $over_time ? date('Y-m-d H:i:s', $over_time) : '';
 
-         });
 
-         $show->created_at('创建时间');
 
-         $show->updated_at('更新时间');
 
-         return $show;
 
-     }
 
-     /**
 
-      * Make a form builder.
 
-      *
 
-      * @return Form
 
-      */
 
-     protected function form()
 
-     {
 
-         $form = new Form(new JobfairCompany);
 
-         $form->display('ID');
 
-         $form->display('Created at');
 
-         $form->display('Updated at');
 
-         return $form;
 
-     }
 
-     public function destroy($id)
 
-     {
 
-         $ids = array();
 
-         if ($id) {
 
-             $ids = explode(',', $id);
 
-         }
 
-         if (!$ids) {
 
-             return admin_toastr('请勾选需要删除的职位', 'error');
 
-         }
 
-         \DB::beginTransaction();
 
-         try {
 
-             JobfairCompany::whereIn('id', $ids)->update(['type'=>4]);
 
-             $data = [
 
-                 'status'  => true,
 
-                 'message' => '删除成功!',
 
-             ];
 
-             \DB::commit();
 
-             return response()->json($data);
 
-         } catch (\Exception $e) {
 
-             \DB::rollback();
 
-             $data = [
 
-                 'status'  => false,
 
-                 'message' => '删除失败!',
 
-             ];
 
-             return response()->json($data);
 
-         }
 
-     }
 
- }
 
 
  |