WxPostsPayContentController.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace App\Admin\Controllers\Posts;
  3. use App\Admin\Repositories\Posts\WxPostsPayContent;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class WxPostsPayContentController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new WxPostsPayContent(), function (Grid $grid) {
  18. $grid->simplePaginate();
  19. $grid->model()->orderBy('id', 'desc');
  20. $grid->quickSearch(['id','post_id','hidden'])->placeholder('搜索id,笔记id,隐藏内容...')->width(50);
  21. $grid->column('id')->sortable();
  22. $grid->column('post_id')->sortable();
  23. $grid->column('words_percent')->sortable();
  24. $grid->column('is_file')->sortable();
  25. $grid->column('is_sound')->sortable();
  26. $grid->column('hidden')->limit(30);
  27. $grid->column('price')->sortable();
  28. $grid->column('credit_type', '货币类型')->sortable();
  29. $grid->column('created_at')->sortable();
  30. // $grid->column('updated_at')->sortable();
  31. $grid->filter(function (Grid\Filter $filter) {
  32. $filter->equal('id');
  33. $filter->equal('post_id');
  34. });
  35. $grid->disableCreateButton();
  36. $grid->disableBatchActions();
  37. $grid->disableDeleteButton();
  38. });
  39. }
  40. /**
  41. * Make a show builder.
  42. *
  43. * @param mixed $id
  44. *
  45. * @return Show
  46. */
  47. protected function detail($id)
  48. {
  49. return Show::make($id, new WxPostsPayContent(), function (Show $show) {
  50. $show->field('id');
  51. $show->field('post_id');
  52. $show->field('words_percent');
  53. $show->field('is_file');
  54. $show->field('is_sound');
  55. $show->field('hidden');
  56. $show->field('price');
  57. $show->field('credit_type', '货币类型');
  58. $show->field('created_at');
  59. $show->field('updated_at');
  60. $show->disableDeleteButton();
  61. });
  62. }
  63. /**
  64. * Make a form builder.
  65. *
  66. * @return Form
  67. */
  68. protected function form()
  69. {
  70. return Form::make(new WxPostsPayContent(), function (Form $form) {
  71. $form->display('id');
  72. $form->text('post_id')->disable();
  73. $form->rate('words_percent');
  74. $form->radio('is_file')->options([0=>'否', 1=>'是']);
  75. $form->radio('is_sound')->options([0=>'否', 1=>'是']);
  76. $form->textarea('hidden');
  77. $form->text('price');
  78. $form->radio('credit_type', '货币类型')->options([0=>'金币', 1=>'余额']);
  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. }