WxXiangqinController.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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\WxXiangqin;
  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 WxXiangqinController extends AdminController
  17. {
  18. /**
  19. * Make a grid builder.
  20. *
  21. * @return Grid
  22. */
  23. protected function grid()
  24. {
  25. return Grid::make(new WxXiangqin(), 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->model()->orderBy('id', 'desc');
  31. $grid->column('id')->sortable();
  32. // $grid->column('poster')->image('',80);
  33. // $grid->column('sort')->editable();
  34. $grid->column('type')->using(FieldUtils::getUrlTypesOne())->label([
  35. 'default' => 'primary', // 设置默认颜色,不设置则默认为 default
  36. ]);
  37. $grid->column('target_id', '跳转id');
  38. // $grid->column('slideshow_state')->switch();
  39. // $grid->column('created_at');
  40. $grid->column('updated_at')->sortable();
  41. $grid->filter(function (Grid\Filter $filter) {
  42. $filter->equal('id');
  43. });
  44. $grid->disableViewButton();
  45. $grid->disableCreateButton();
  46. });
  47. }
  48. /**
  49. * Make a show builder.
  50. *
  51. * @param mixed $id
  52. *
  53. * @return Show
  54. */
  55. protected function detail($id)
  56. {
  57. return Show::make($id, new WxXiangqin(), function (Show $show) {
  58. $show->field('id');
  59. $show->field('poster');
  60. $show->field('target_id');
  61. $show->field('slideshow_type');
  62. $show->field('slideshow_state');
  63. $show->field('created_at');
  64. $show->field('updated_at');
  65. });
  66. }
  67. /**
  68. * Make a form builder.
  69. *
  70. * @return Form
  71. */
  72. protected function form()
  73. {
  74. return Form::make(new WxXiangqin(), function (Form $form) {
  75. $form->display('id')->help('<a href="#" >路径大全</a>');;
  76. // $form->radio('slideshow_type')->options(FieldUtils::getUrlTypes())->default(0)->required();
  77. $form->text('target_id', '跳转id')->help('<a href="https://doc.minisns.cn/doc/44/" target="_blank">路径大全</a>');
  78. // $form->switch('slideshow_state');
  79. global $__MINI_GLOBAL_TENANT_ID__;
  80. if($__MINI_GLOBAL_TENANT_ID__ > 0){
  81. $form->text('tenant_id', '本站分应用id')->help('忽略这个配置')->default($__MINI_GLOBAL_TENANT_ID__);
  82. }
  83. $form->saving(function (Form $form){
  84. global $__MINI_GLOBAL_TENANT_ID__;
  85. $form->tenant_id = $__MINI_GLOBAL_TENANT_ID__;
  86. });
  87. $form->deleting(function (Form $form){
  88. global $__MINI_GLOBAL_TENANT_ID__;
  89. if($__MINI_GLOBAL_TENANT_ID__ > 0){
  90. return $form->response()->error('权限不足,不可以删除其他分站对象');
  91. }
  92. });
  93. });
  94. }
  95. }