WxLiwuController.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Wen\Utils\FieldUtils;
  4. use App\Wen\Utils\Utils;
  5. use App\Models\Posts\WxPost;
  6. use App\Models\Posts\WxTag;
  7. use App\Models\Circle\WxCircle;
  8. use App\Models\Shop\WxShopGoods;
  9. use App\Models\WxSlideshow;
  10. use App\Models\WxGift;
  11. use App\Models\User\WxUser;
  12. use Dcat\Admin\Form;
  13. use Dcat\Admin\Grid;
  14. use Dcat\Admin\Show;
  15. use Dcat\Admin\Http\Controllers\AdminController;
  16. class WxLiwuController extends AdminController
  17. {
  18. /**
  19. * Make a grid builder.
  20. *
  21. * @return Grid
  22. */
  23. protected function grid()
  24. {
  25. return Grid::make(new WxGift(), function (Grid $grid) {
  26. global $__MINI_GLOBAL_TENANT_ID__;
  27. if($__MINI_GLOBAL_TENANT_ID__ > 0){
  28. $grid->model()->where('tenant_id', '=', $__MINI_GLOBAL_TENANT_ID__);
  29. }
  30. $grid->column('name');
  31. $grid->model()->orderBy('id', 'desc');
  32. $grid->column('id')->sortable();
  33. $grid->column('photo_url')->image('',80);
  34. $grid->column('price');
  35. // $grid->column('slideshow_state')->switch();
  36. // $grid->column('created_at');
  37. //$grid->column('updated_at')->sortable();
  38. $grid->filter(function (Grid\Filter $filter) {
  39. $filter->equal('id');
  40. });
  41. $grid->disableViewButton();
  42. //$grid->disableCreateButton();
  43. });
  44. }
  45. /**
  46. * Make a show builder.
  47. *
  48. * @param mixed $id
  49. *
  50. * @return Show
  51. */
  52. protected function detail($id)
  53. {
  54. return Show::make($id, new WxGift(), function (Show $show) {
  55. $show->field('id');
  56. $show->field('name');
  57. $show->field('price');
  58. $show->field('photo_url')->image('',80);
  59. $show->field('created_at');
  60. $show->field('updated_at');
  61. });
  62. }
  63. /**
  64. * Make a form builder.
  65. *
  66. * @return Form
  67. */
  68. protected function form()
  69. {
  70. return Form::make(new WxGift(), function (Form $form) {
  71. $form->display('id');
  72. $form->text('name', '名称');
  73. $form->text('price', '价格');
  74. $form->image('photo_url')->url('files/uploads')->autoUpload();
  75. $form->saving(function (Form $form){
  76. global $__MINI_GLOBAL_TENANT_ID__;
  77. $form->tenant_id = $__MINI_GLOBAL_TENANT_ID__;
  78. });
  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. }