123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- <?php
- namespace App\Admin\Controllers\Person;
- use App\Http\Controllers\Controller;
- use App\Models\HrBind;
- 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 HrBindController extends Controller
- {
- use HasResourceActions;
- /**
- * Index interface.
- *
- * @param Content $content
- * @return Content
- */
- public function index(Content $content)
- {
- return $content
- ->header('HR列表')
- ->description(' ')
- ->body($this->grid());
- }
- /**
- * Show interface.
- *
- * @param mixed $id
- * @param Content $content
- * @return Content
- */
- public function show($id, Content $content)
- {
- return $content
- ->header('Detail')
- ->description('description')
- ->body($this->detail($id));
- }
- /**
- * Edit interface.
- *
- * @param mixed $id
- * @param Content $content
- * @return Content
- */
- public function edit($id, Content $content)
- {
- return $content
- ->header('Edit')
- ->description('description')
- ->body($this->form()->edit($id));
- }
- /**
- * Create interface.
- *
- * @param Content $content
- * @return Content
- */
- public function create(Content $content)
- {
- return $content
- ->header('Create')
- ->description('description')
- ->body($this->form());
- }
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- $grid = new Grid(new HrBind);
- $grid->column('memberInfo.username', '用户名')->width(200);
- $grid->column('companyInfo.companyname', '所在企业')->width(200);
- $grid->column('memberInfo.mobile', '电话')->width(100);
- $grid->column('memberInfo.email', '邮箱')->width(150);
- $grid->status('绑定状态')->display(function () {
- return $this->status?'绑定':'解绑';
- });
- $grid->binded_at('操作时间');
- if (Admin::user()->can('person_hr_delete')) {
- $grid->disableActions();
- $grid->tools(function (Grid\Tools $tools) {
- $tools->batch(function ($batch) {
- $batch->disableDelete(false);
- });
- });
- }
- $grid->filter(function ($filter) {
- $filter->disableIdFilter();
- $filter->column(1/2, function ($filter) {
- $filter->like('memberInfo.username', '用户名');
- $filter->like('companyInfo.companyname', '企业名称');
- });
- $filter->column(1/2, function ($filter) {
- $filter->like('memberInfo.mobile', '电话');
- $filter->like('memberInfo.email', 'Email');
- });
- });
- return $grid;
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- * @return Show
- */
- protected function detail($id)
- {
- $show = new Show(HrBind::findOrFail($id));
- $show->id('ID');
- $show->created_at('Created at');
- $show->updated_at('Updated at');
- return $show;
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- $form = new Form(new HrBind);
- $form->display('ID');
- $form->display('Created at');
- $form->display('Updated at');
- return $form;
- }
- }
|