InsuranceAgreementController.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace App\Admin\Controllers\ServicePacksManagment;
  3. use App\Models\InsuranceAgreement;
  4. use Encore\Admin\Controllers\AdminController;
  5. use Encore\Admin\Form;
  6. use Encore\Admin\Grid;
  7. use Encore\Admin\Show;
  8. class InsuranceAgreementController extends AdminController
  9. {
  10. /**
  11. * Title for current resource.
  12. *
  13. * @var string
  14. */
  15. protected $title = '保险协议列表';
  16. /**
  17. * Make a grid builder.
  18. *
  19. * @return Grid
  20. */
  21. protected function grid()
  22. {
  23. $grid = new Grid(new InsuranceAgreement());
  24. $grid->disableBatchActions();
  25. $grid->disableCreateButton();
  26. $grid->actions(function ($actions){
  27. $actions->disableView();
  28. });
  29. $grid->column('id', __('Id'));
  30. $grid->column('name', __('协议名称'));
  31. $grid->column('content', __('协议内容'))->limit(20,'...');
  32. $status = [
  33. 'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
  34. 'on' => ['value' => 1, 'text' => '启用', 'color' => 'success'],
  35. ];
  36. $grid->column('status', __('状态'))->switch($status);
  37. $grid->column('created_at', __('创建时间'));
  38. $grid->column('updated_at', __('更新时间'));
  39. return $grid;
  40. }
  41. /**
  42. * Make a show builder.
  43. *
  44. * @param mixed $id
  45. * @return Show
  46. */
  47. /**
  48. * Make a form builder.
  49. *
  50. * @return Form
  51. */
  52. protected function form()
  53. {
  54. $form = new Form(new InsuranceAgreement());
  55. $form->text('name', __('协议名称'));
  56. $form->editor('content', __('协议内容'));
  57. $status = [
  58. 'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
  59. 'on' => ['value' => 1, 'text' => '启用', 'color' => 'success'],
  60. ];
  61. $form->switch('status', __('状态'))->states($status)->default(1);
  62. return $form;
  63. }
  64. }