WxUsedClassifyController.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace App\Admin\Controllers\Used;
  3. use App\Admin\Repositories\Used\WxUsedClassify;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class WxUsedClassifyController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new WxUsedClassify(), function (Grid $grid) {
  18. $grid->model()->orderBy('order', 'desc')->orderBy('id', 'desc');
  19. $grid->quickSearch(['id', 'name','desc'])->placeholder('搜索ID,名字,简介...')->width(50);
  20. $grid->column('id')->sortable();
  21. $grid->column('order')->editable()->sortable();
  22. $grid->column('name');
  23. $grid->column('desc');
  24. $grid->column('pic')->image('', 80, 80);
  25. $grid->column('bg_img')->image('', 80, 80);
  26. $grid->column('status')->switch();
  27. $grid->column('created_at')->sortable();
  28. // $grid->column('updated_at')->sortable();
  29. $grid->filter(function (Grid\Filter $filter) {
  30. $filter->equal('id');
  31. });
  32. });
  33. }
  34. /**
  35. * Make a show builder.
  36. *
  37. * @param mixed $id
  38. *
  39. * @return Show
  40. */
  41. protected function detail($id)
  42. {
  43. return Show::make($id, new WxUsedClassify(), function (Show $show) {
  44. $show->field('id');
  45. $show->field('order');
  46. $show->field('name');
  47. $show->field('desc');
  48. $show->field('pic');
  49. $show->field('bg_img');
  50. $show->field('status');
  51. $show->field('created_at');
  52. $show->field('updated_at');
  53. });
  54. }
  55. /**
  56. * Make a form builder.
  57. *
  58. * @return Form
  59. */
  60. protected function form()
  61. {
  62. return Form::make(new WxUsedClassify(), function (Form $form) {
  63. $form->display('id');
  64. $form->number('order')->default(0);
  65. $form->text('name')->help('建议不超过4字')->required();
  66. $form->textarea('desc')->required();
  67. $form->image('pic')->url('files/uploads')->uniqueName()->autoUpload()->required();
  68. $form->image('bg_img')->url('files/uploads')->uniqueName()->autoUpload()->required();
  69. $form->switch('status')->default(1);
  70. $form->display('created_at');
  71. $form->display('updated_at');
  72. $form->deleting(function (Form $form){
  73. global $__MINI_GLOBAL_TENANT_ID__;
  74. if($__MINI_GLOBAL_TENANT_ID__ > 0){
  75. return $form->response()->error('权限不足,不可以删除其他分站对象');
  76. }
  77. });
  78. });
  79. }
  80. }