WxVoterTemplateController.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. namespace App\Admin\Controllers\Voter;
  3. use App\Admin\Repositories\Voter\WxVoterTemplate;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class WxVoterTemplateController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new WxVoterTemplate(), function (Grid $grid) {
  18. $grid->model()->orderBy('id', 'desc');
  19. $grid->column('id')->sortable();
  20. $grid->column('status')->switch();
  21. // $grid->column('recommend');
  22. $grid->column('sort')->editable();
  23. $grid->column('name')->editable();
  24. // $grid->column('template_type');
  25. $grid->column('cover')->image();
  26. // $grid->column('banner');
  27. // $grid->column('main_background_image');
  28. // $grid->column('user_background_image');
  29. $grid->column('background_color')->editable();
  30. $grid->column('text_color')->editable();
  31. $grid->column('main_color')->editable();
  32. $grid->column('button_bg_color')->editable();
  33. $grid->column('button_text_color')->editable();
  34. $grid->column('text_navigation_bar_color')->editable();
  35. // $grid->column('created_at');
  36. $grid->column('updated_at')->sortable();
  37. $grid->filter(function (Grid\Filter $filter) {
  38. $filter->equal('id');
  39. });
  40. });
  41. }
  42. /**
  43. * Make a show builder.
  44. *
  45. * @param mixed $id
  46. *
  47. * @return Show
  48. */
  49. protected function detail($id)
  50. {
  51. return Show::make($id, new WxVoterTemplate(), function (Show $show) {
  52. $show->field('id');
  53. $show->field('status');
  54. $show->field('recommend');
  55. $show->field('sort');
  56. $show->field('name');
  57. $show->field('template_type');
  58. $show->field('cover');
  59. $show->field('banner');
  60. $show->field('main_background_image');
  61. $show->field('user_background_image');
  62. $show->field('background_color');
  63. $show->field('text_color');
  64. $show->field('main_color');
  65. $show->field('button_bg_color');
  66. $show->field('button_text_color');
  67. $show->field('text_navigation_bar_color');
  68. $show->field('created_at');
  69. $show->field('updated_at');
  70. });
  71. }
  72. /**
  73. * Make a form builder.
  74. *
  75. * @return Form
  76. */
  77. protected function form()
  78. {
  79. return Form::make(new WxVoterTemplate(), function (Form $form) {
  80. $form->display('id');
  81. $form->switch('status')->default(1);
  82. // $form->text('recommend');
  83. // $form->text('sort');
  84. $form->text('name')->required();
  85. // $form->text('template_type');
  86. $form->image('cover')->url('files/uploads')->autoUpload()->required();
  87. $form->multipleImage('banner')->url('files/uploads')->autoUpload()->saveAsJson()->required();
  88. $form->image('main_background_image')->url('files/uploads')->autoUpload();
  89. $form->image('user_background_image');
  90. $form->color('background_color')->required();
  91. $form->color('text_color')->required();
  92. $form->color('main_color')->required();
  93. $form->color('button_bg_color')->required();
  94. $form->color('button_text_color')->required();
  95. $form->color('text_navigation_bar_color')->required()->default('#000000');
  96. $form->display('created_at');
  97. $form->display('updated_at');
  98. $form->deleting(function (Form $form){
  99. global $__MINI_GLOBAL_TENANT_ID__;
  100. if($__MINI_GLOBAL_TENANT_ID__ > 0){
  101. return $form->response()->error('权限不足,不可以删除其他分站对象');
  102. }
  103. });
  104. });
  105. }
  106. }