WxNavigationPlateController.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Admin\Repositories\WxNavigationPlate;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class WxNavigationPlateController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new WxNavigationPlate(), function (Grid $grid) {
  18. $grid->simplePaginate();
  19. $grid->model()->orderBy('id', 'desc');
  20. $grid->column('id')->sortable();
  21. $grid->column('name');
  22. $grid->column('introduce');
  23. $grid->column('sort')->editable();
  24. $grid->column('superior_id');
  25. $grid->column('type')->using([0 => '资源素材', 1 => '工具利器'])->label([
  26. 0 => 'primary',
  27. 1 => 'blue',
  28. ]);
  29. $grid->column('state')->using([0 => '正常', 1 => '下架'])->label([
  30. 0 => 'primary',
  31. 1 => 'red',
  32. ]);
  33. // $grid->column('created_at');
  34. $grid->column('updated_at')->sortable();
  35. $grid->filter(function (Grid\Filter $filter) {
  36. $filter->equal('id');
  37. });
  38. });
  39. }
  40. /**
  41. * Make a show builder.
  42. *
  43. * @param mixed $id
  44. *
  45. * @return Show
  46. */
  47. protected function detail($id)
  48. {
  49. return Show::make($id, new WxNavigationPlate(), function (Show $show) {
  50. $show->field('id');
  51. $show->field('name');
  52. $show->field('introduce');
  53. $show->field('sort');
  54. $show->field('superior_id');
  55. $show->field('type');
  56. $show->field('state');
  57. $show->field('created_at');
  58. $show->field('updated_at');
  59. });
  60. }
  61. /**
  62. * Make a form builder.
  63. *
  64. * @return Form
  65. */
  66. protected function form()
  67. {
  68. return Form::make(new WxNavigationPlate(), function (Form $form) {
  69. $form->display('id');
  70. $form->text('name');
  71. $form->text('introduce');
  72. $form->text('sort');
  73. $form->text('superior_id');
  74. $form->text('type');
  75. $form->text('state');
  76. $form->deleting(function (Form $form){
  77. global $__MINI_GLOBAL_TENANT_ID__;
  78. if($__MINI_GLOBAL_TENANT_ID__ > 0){
  79. return $form->response()->error('权限不足,不可以删除其他分站对象');
  80. }
  81. });
  82. });
  83. }
  84. }