123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- namespace App\Admin\Controllers;
- use App\Models\DocterType;
- use Encore\Admin\Controllers\AdminController;
- use Encore\Admin\Form;
- use Encore\Admin\Grid;
- use Encore\Admin\Show;
- class DocterTypeController extends AdminController
- {
- /**
- * Title for current resource.
- *
- * @var string
- */
- protected $title = '医生类型';
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- $grid = new Grid(new DocterType());
- $grid->filter(function ($filter){
- $filter->disableIdFilter();
- $filter->like('name','名称');
- });
- $grid->column('id', __('ID'));
- $grid->column('name', __('名称'));
- $states = [
- 'off' => ['value' => 0, 'text' => '关闭', 'color' => 'danger'],
- 'on' => ['value' => 1, 'text' => '打开', 'color' => 'success'],
- ];
- $grid->column('status', __('状态'))->switch($states);
- $grid->column('created_at', __('创建时间'));
- $grid->column('updated_at', __('更新时间'));
- $grid->actions(function($actions){
- $actions->disableDelete();
- });
- return $grid;
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- * @return Show
- */
- protected function detail($id)
- {
- $show = new Show(DocterType::findOrFail($id));
- $show->field('id', __('Id'));
- $show->field('name', __('名称'));
- $show->field('status', __('启用禁用'));
- $show->field('created_at', __('创建时间'));
- $show->field('updated_at', __('更新时间'));
- return $show;
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- $form = new Form(new DocterType());
- $form->text('name', __('名称'));
- $states = [
- 'off' => ['value' => 0, 'text' => '关闭', 'color' => 'danger'],
- 'on' => ['value' => 1, 'text' => '打开', 'color' => 'success'],
- ];
- $form->switch('status', __('名称'))->states($states);
- $form->tools(function (Form\Tools $tools) {
- $tools->disableDelete();
- $tools->disableView();
- });
- $form->disableEditingCheck();
- $form->disableCreatingCheck();
- $form->disableViewCheck();
- return $form;
- }
- }
|