WxShopServiceController.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace App\Admin\Controllers\Shop;
  3. use App\Admin\Repositories\Shop\WxShopService;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class WxShopServiceController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new WxShopService(), function (Grid $grid) {
  18. $grid->quickSearch(['id', 'name', 'intro'])->placeholder('搜索条款ID,名字,内容等...')->width(30);
  19. $grid->column('id')->sortable();
  20. $grid->column('name');
  21. $grid->column('intro');
  22. $grid->column('sort')->editable();
  23. $grid->column('state')->switch();
  24. $grid->column('created_at');
  25. $grid->filter(function (Grid\Filter $filter) {
  26. $filter->equal('id');
  27. });
  28. $grid->disableBatchDelete();
  29. $grid->disableBatchDelete();
  30. // $grid->disableDeleteButton();
  31. $grid->header(function ($collection) {
  32. return '<div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;display: inline-block;margin-top: 20px;">
  33. 小提示: “不支持7天无理由退货(id:1)”和“7天无理由退货(id:2)”不可以删除,系统自带的也尽量不要删除,因为系统会依据你所选择的服务,做对应的调整,比如不支持7天无理由退货时,则对应的商品就不会出现退货按钮。</div>';
  34. });
  35. });
  36. }
  37. /**
  38. * Make a show builder.
  39. *
  40. * @param mixed $id
  41. *
  42. * @return Show
  43. */
  44. protected function detail($id)
  45. {
  46. return Show::make($id, new WxShopService(), function (Show $show) {
  47. $show->field('id');
  48. $show->field('name');
  49. $show->field('intro');
  50. $show->field('sort');
  51. $show->field('state');
  52. $show->field('created_at');
  53. $show->field('updated_at');
  54. });
  55. }
  56. /**
  57. * Make a form builder.
  58. *
  59. * @return Form
  60. */
  61. protected function form()
  62. {
  63. return Form::make(new WxShopService(), function (Form $form) {
  64. $form->display('id');
  65. $form->text('name');
  66. $form->text('intro');
  67. $form->number('sort');
  68. $form->switch('state');
  69. $form->deleting(function (Form $form){
  70. global $__MINI_GLOBAL_TENANT_ID__;
  71. if($__MINI_GLOBAL_TENANT_ID__ > 0){
  72. return $form->response()->error('权限不足,不可以删除其他分站对象');
  73. }
  74. if($form->id >= 1 && $form->id <= 5){
  75. return $form->response()->error('不能删除1-5的商品服务!');
  76. }
  77. });
  78. });
  79. }
  80. }