1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace App\Admin\Controllers\ServicePacksManagment;
- use App\Models\InsuranceAgreement;
- use Encore\Admin\Controllers\AdminController;
- use Encore\Admin\Form;
- use Encore\Admin\Grid;
- use Encore\Admin\Show;
- class InsuranceAgreementController extends AdminController
- {
- /**
- * Title for current resource.
- *
- * @var string
- */
- protected $title = '保险协议列表';
- /**
- * Make a grid builder.
- *
- * @return Grid
- */
- protected function grid()
- {
- $grid = new Grid(new InsuranceAgreement());
- $grid->disableBatchActions();
- $grid->filter(function ($filter){
- $filter->disableIdFilter();
- $filter->like('name','协议名称');
- });
- $grid->column('id', __('Id'));
- $grid->column('name', __('协议名称'));
- // $grid->column('content', __('协议内容'))->limit('300','...');
- $status = [
- 'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
- 'on' => ['value' => 1, 'text' => '启用', 'color' => 'success'],
- ];
- $grid->column('status', __('状态'))->switch($status);
- $grid->column('created_at', __('创建时间'));
- $grid->column('updated_at', __('更新时间'));
- return $grid;
- }
- /**
- * Make a show builder.
- *
- * @param mixed $id
- * @return Show
- */
- protected function detail($id)
- {
- $show = new Show(InsuranceAgreement::findOrFail($id));
- $show->field('id', 'ID');
- $show->field('name', '协议名称');
- $show->field('content', '协议内容')->unescape();
- $show->field('status', '状态')->using([0=>'禁用',1=>'启用'])->label('info');
- $show->field('created_at', '创建时间');
- $show->field('updated_at', '更新时间');
- return $show;
- }
- /**
- * Make a form builder.
- *
- * @return Form
- */
- protected function form()
- {
- $form = new Form(new InsuranceAgreement());
- $form->text('name', __('协议名称'));
- $form->editor('content', __('协议内容'));
- $status = [
- 'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
- 'on' => ['value' => 1, 'text' => '启用', 'color' => 'success'],
- ];
- $form->switch('status', __('状态'))->states($status)->default(1);
- return $form;
- }
- }
|