DistAdminDistributorController.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Admin\Repositories\DistAdminDistributor;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. use Dcat\Admin\Layout\Content;
  9. use Dcat\Admin\Admin;
  10. class DistAdminDistributorController extends AdminController
  11. {
  12. /**
  13. * page index
  14. */
  15. public function index(Content $content)
  16. {
  17. return $content
  18. ->header('Distro Management')
  19. ->description('all')
  20. ->breadcrumb(['text'=>'list','url'=>''])
  21. ->body($this->grid());
  22. }
  23. /**
  24. * Make a grid builder.
  25. *
  26. * @return Grid
  27. */
  28. protected function grid()
  29. {
  30. return Grid::make(new DistAdminDistributor(), function (Grid $grid) {
  31. $grid->column('id')->sortable();
  32. $grid->column('company_name','Company Name');
  33. $grid->column('site_name');
  34. $grid->column('level_domain');
  35. $grid->column('country');
  36. $grid->column('contact_number');
  37. $grid->column('service_hotline');
  38. $grid->column('enabled')->switch();
  39. $grid->column('created_at');
  40. $grid->column('updated_at')->sortable();
  41. // 过滤
  42. $grid->filter(function (Grid\Filter $filter) {
  43. $filter->equal('company_name');
  44. $filter->equal('site_name');
  45. $filter->equal('level_domain');
  46. });
  47. // 排序
  48. $grid->model()->orderBy("id",'desc');
  49. //按钮
  50. $grid->showQuickEditButton();
  51. $grid->enableDialogCreate();
  52. $grid->disableEditButton();
  53. $grid->disableDeleteButton();
  54. $grid->disableBatchDelete();
  55. });
  56. }
  57. /**
  58. * Make a show builder.
  59. *
  60. * @param mixed $id
  61. *
  62. * @return Show
  63. */
  64. protected function detail($id)
  65. {
  66. return Show::make($id, new DistAdminDistributor(), function (Show $show) {
  67. $show->field('id');
  68. $show->field('country');
  69. $show->field('contact_number');
  70. $show->field('service_hotline');
  71. $show->field('whats_app');
  72. $show->field('facebook');
  73. $show->field('instagram');
  74. $show->field('youtube');
  75. $show->field('linkedin');
  76. $show->field('tiktok');
  77. $show->field('site_name');
  78. $show->field('level_domain');
  79. $show->field('remark');
  80. $show->field('company_address');
  81. $show->field('company_name');
  82. $show->field('enabled');
  83. $show->field('created_at');
  84. $show->field('updated_at');
  85. });
  86. }
  87. /**
  88. * Make a form builder.
  89. *
  90. * @return Form
  91. */
  92. protected function form()
  93. {
  94. return Form::make(new DistAdminDistributor(), function (Form $form) {
  95. $form->display('id');
  96. $form->text('company_name');
  97. $form->text('site_name');
  98. $form->text('level_domain');
  99. $form->text('country');
  100. $form->text('contact_number');
  101. $form->text('service_hotline');
  102. $form->text('whats_app');
  103. $form->text('facebook');
  104. $form->text('instagram');
  105. $form->text('youtube');
  106. $form->text('linkedin');
  107. $form->text('tiktok');
  108. $form->switch('enabled')->default(1);
  109. $form->text('company_address');
  110. $form->textarea('remark');
  111. $form->display('created_at');
  112. $form->display('updated_at');
  113. //保存后回调
  114. $form->saved(function (Form $form, $result) {
  115. });
  116. });
  117. }
  118. }