| xqd
@@ -0,0 +1,93 @@
|
|
|
+<?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->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;
|
|
|
+ }
|
|
|
+}
|