WxPostsVoteController.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. namespace App\Admin\Controllers\Posts;
  3. use App\Admin\Repositories\Posts\WxPostsVote;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class WxPostsVoteController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new WxPostsVote(), function (Grid $grid) {
  18. $grid->simplePaginate();
  19. $grid->model()->orderBy('id', 'desc');
  20. $grid->column('id')->sortable();
  21. $grid->column('post_id');
  22. $grid->column('option1');
  23. $grid->column('num1');
  24. $grid->column('option2');
  25. $grid->column('num2');
  26. $grid->column('option3');
  27. $grid->column('num3');
  28. $grid->column('option4');
  29. $grid->column('num4');
  30. $grid->column('option5');
  31. $grid->column('num5');
  32. // $grid->column('created_at');
  33. // $grid->column('updated_at')->sortable();
  34. $grid->filter(function (Grid\Filter $filter) {
  35. $filter->equal('id');
  36. });
  37. $grid->disableActions();
  38. $grid->disableBatchActions();
  39. $grid->disableCreateButton();
  40. });
  41. }
  42. /**
  43. * Make a show builder.
  44. *
  45. * @param mixed $id
  46. *
  47. * @return Show
  48. */
  49. protected function detail($id)
  50. {
  51. return Show::make($id, new WxPostsVote(), function (Show $show) {
  52. $show->field('id');
  53. $show->field('post_id');
  54. $show->field('option1');
  55. $show->field('num1');
  56. $show->field('option2');
  57. $show->field('num2');
  58. $show->field('option3');
  59. $show->field('num3');
  60. $show->field('option4');
  61. $show->field('num4');
  62. $show->field('option5');
  63. $show->field('num5');
  64. $show->field('created_at');
  65. $show->field('updated_at');
  66. });
  67. }
  68. /**
  69. * Make a form builder.
  70. *
  71. * @return Form
  72. */
  73. protected function form()
  74. {
  75. return Form::make(new WxPostsVote(), function (Form $form) {
  76. $form->display('id');
  77. $form->text('post_id');
  78. $form->text('option1');
  79. $form->text('num1');
  80. $form->text('option2');
  81. $form->text('num2');
  82. $form->text('option3');
  83. $form->text('num3');
  84. $form->text('option4');
  85. $form->text('num4');
  86. $form->text('option5');
  87. $form->text('num5');
  88. $form->display('created_at');
  89. $form->display('updated_at');
  90. $form->deleting(function (Form $form){
  91. global $__MINI_GLOBAL_TENANT_ID__;
  92. if($__MINI_GLOBAL_TENANT_ID__ > 0){
  93. return $form->response()->error('权限不足,不可以删除其他分站对象');
  94. }
  95. });
  96. });
  97. }
  98. }