WxNavigationController.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Admin\Repositories\WxNavigation;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class WxNavigationController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new WxNavigation('plate'), function (Grid $grid) {
  18. $grid->column('id')->sortable();
  19. $grid->column('sort')->editable();
  20. $grid->column('plate.name', '所属板块');
  21. $grid->column('icon')->image('', 50);
  22. $grid->column('link');
  23. $grid->column('name');
  24. $grid->column('introduce');
  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('updated_at')->sortable();
  34. $grid->filter(function (Grid\Filter $filter) {
  35. $filter->equal('id');
  36. });
  37. });
  38. }
  39. /**
  40. * Make a show builder.
  41. *
  42. * @param mixed $id
  43. *
  44. * @return Show
  45. */
  46. protected function detail($id)
  47. {
  48. return Show::make($id, new WxNavigation(), function (Show $show) {
  49. $show->field('id');
  50. $show->field('np_id');
  51. $show->field('icon');
  52. $show->field('link');
  53. $show->field('name');
  54. $show->field('introduce');
  55. $show->field('sort');
  56. $show->field('type');
  57. $show->field('state');
  58. $show->field('created_at');
  59. $show->field('updated_at');
  60. });
  61. }
  62. /**
  63. * Make a form builder.
  64. *
  65. * @return Form
  66. */
  67. protected function form()
  68. {
  69. return Form::make(new WxNavigation(), function (Form $form) {
  70. $form->display('id');
  71. $form->text('np_id');
  72. $form->image('icon')->url('files/uploads')->uniqueName();
  73. $form->text('link');
  74. $form->text('name');
  75. $form->text('introduce');
  76. $form->text('sort');
  77. $form->text('type');
  78. $form->text('state');
  79. $form->deleting(function (Form $form){
  80. global $__MINI_GLOBAL_TENANT_ID__;
  81. if($__MINI_GLOBAL_TENANT_ID__ > 0){
  82. return $form->response()->error('权限不足,不可以删除其他分站对象');
  83. }
  84. });
  85. });
  86. }
  87. }