InsuranceAgreementController.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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->actions(function ($actions){
  26. $actions->disableView();
  27. });
  28. $grid->column('id', __('Id'));
  29. $grid->column('name', __('协议名称'));
  30. $grid->column('content', __('协议内容'))->limit(20,'...');
  31. $status = [
  32. 'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
  33. 'on' => ['value' => 1, 'text' => '启用', 'color' => 'success'],
  34. ];
  35. $grid->column('status', __('状态'))->switch($status);
  36. $grid->column('created_at', __('创建时间'));
  37. $grid->column('updated_at', __('更新时间'));
  38. return $grid;
  39. }
  40. /**
  41. * Make a show builder.
  42. *
  43. * @param mixed $id
  44. * @return Show
  45. */
  46. /**
  47. * Make a form builder.
  48. *
  49. * @return Form
  50. */
  51. protected function form()
  52. {
  53. $form = new Form(new InsuranceAgreement());
  54. $form->text('name', __('协议名称'));
  55. $form->editor('content', __('协议内容'));
  56. $status = [
  57. 'off' => ['value' => 0, 'text' => '禁用', 'color' => 'danger'],
  58. 'on' => ['value' => 1, 'text' => '启用', 'color' => 'success'],
  59. ];
  60. $form->switch('status', __('状态'))->states($status)->default(1);
  61. return $form;
  62. }
  63. }