WxShopNoticeController.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. namespace App\Admin\Controllers\Shop;
  3. use App\Admin\Repositories\Shop\WxShopNotice;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class WxShopNoticeController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new WxShopNotice(), function (Grid $grid) {
  18. $grid->simplePaginate();
  19. $grid->model()->orderBy('id', 'desc');
  20. $grid->column('id')->sortable();
  21. $grid->column('title');
  22. $grid->column('content')->limit(8);
  23. $grid->column('state')->switch();
  24. $grid->column('created_at');
  25. $grid->column('updated_at')->sortable();
  26. $grid->filter(function (Grid\Filter $filter) {
  27. $filter->equal('id');
  28. });
  29. });
  30. }
  31. /**
  32. * Make a show builder.
  33. *
  34. * @param mixed $id
  35. *
  36. * @return Show
  37. */
  38. protected function detail($id)
  39. {
  40. return Show::make($id, new WxShopNotice(), function (Show $show) {
  41. $show->field('id');
  42. $show->field('title');
  43. $show->field('content');
  44. $show->field('state');
  45. $show->field('created_at');
  46. $show->field('updated_at');
  47. });
  48. }
  49. /**
  50. * Make a form builder.
  51. *
  52. * @return Form
  53. */
  54. protected function form()
  55. {
  56. return Form::make(new WxShopNotice(), function (Form $form) {
  57. $form->display('id');
  58. $form->text('title');
  59. if(__system_is_model_enable('laradocs', 'dcat-neditor')){
  60. $form->neditor('content');
  61. }else{
  62. $form->editor('content');
  63. }
  64. $form->switch('state');
  65. $form->deleting(function (Form $form){
  66. global $__MINI_GLOBAL_TENANT_ID__;
  67. if($__MINI_GLOBAL_TENANT_ID__ > 0){
  68. return $form->response()->error('权限不足,不可以删除其他分站对象');
  69. }
  70. });
  71. });
  72. }
  73. }