BannerController.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\Banner;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class BannerController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new Banner(), function (Grid $grid) {
  18. $grid->column('id')->sortable();
  19. $grid->column('title');
  20. $grid->column('sort');
  21. $grid->column('url');
  22. $grid->column('state')->switch();
  23. $grid->column('image_path')->image();
  24. $grid->column('created_at');
  25. $grid->column('updated_at')->sortable();
  26. $grid->filter(function (Grid\Filter $filter) {
  27. $filter->like('title');
  28. $filter->panel();
  29. });
  30. $grid->disableViewButton();
  31. });
  32. }
  33. /**
  34. * Make a show builder.
  35. *
  36. * @param mixed $id
  37. *
  38. * @return Show
  39. */
  40. protected function detail($id)
  41. {
  42. return Show::make($id, new Banner(), function (Show $show) {
  43. $show->field('id');
  44. $show->field('title');
  45. $show->field('sort');
  46. $show->field('url');
  47. $show->field('state');
  48. $show->field('image_path');
  49. $show->field('created_at');
  50. $show->field('updated_at');
  51. });
  52. }
  53. /**
  54. * Make a form builder.
  55. *
  56. * @return Form
  57. */
  58. protected function form()
  59. {
  60. return Form::make(new Banner(), function (Form $form) {
  61. $form->display('id');
  62. $form->text('title')->required();
  63. $form->number('sort')->required();
  64. $form->text('url')->required()->help('
  65. 路径: "/pages/index/index"
  66. 名称: "首页"
  67. 路径: "/pages/my/index",
  68. 名称: "我的"
  69. 路径: "/pages/my/huiBen_record/index",
  70. 名称: "绘本记录"
  71. 路径: "/pages/my/charge/index",
  72. 名称: "充值次数"
  73. 路径: "/pages/my/userInfo/index",
  74. 名称: "个人资料"
  75. 路径: "/pages/index/genHuiBen/index",
  76. 名称: "绘本生成参数填写页"
  77. 路径: "/pages/index/genRes/index",
  78. 名称: "绘本生成结果/绘本详情页"
  79. 路径: "/pages/my/pubCenter/index",
  80. 名称: "推广中心"
  81. 路径: "/pages/my/jiangli/index",
  82. 名称: "推荐奖励"
  83. 路径: "/pages/my/tuiguangDashi/index",
  84. 名称: "推广大使"
  85. 路径: "/pages/my/yongjinDetail/index",
  86. 名称: "佣金明细"
  87. 路径: "/pages/my/cash/index",
  88. 名称: "提现"
  89. 路径: "/pages/my/cashRecord/index",
  90. 名称: "提现记录"
  91. 路径: "/pages/my/team/index",
  92. 名称: "推广团队"
  93. 路径: "/pages/my/kefu/index",
  94. 名称: "客服中心"
  95. ');
  96. $form->switch('state');
  97. $form->image('image_path')->disk('oss')->autoUpload()->saving(function ($res) {
  98. return $res;
  99. })->required();
  100. $form->display('created_at');
  101. $form->display('updated_at');
  102. $form->disableViewButton();
  103. });
  104. }
  105. }