PromotionController.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Models\Config;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. class PromotionController extends AdminController
  9. {
  10. /**
  11. * Make a grid builder.
  12. *
  13. * @return Grid
  14. */
  15. protected function grid()
  16. {
  17. return Grid::make(new Config(), function (Grid $grid) {
  18. $grid->model()->whereIn('id',[14]);
  19. $grid->column('id')->sortable();
  20. $grid->column('desc','标题');
  21. $grid->column('value', '推广背景图')->image();
  22. $grid->column('created_at');
  23. $grid->column('updated_at')->sortable();
  24. $grid->disableDeleteButton();
  25. $grid->disableCreateButton();
  26. $grid->disableViewButton();
  27. });
  28. }
  29. /**
  30. * Make a show builder.
  31. *
  32. * @param mixed $id
  33. *
  34. * @return Show
  35. */
  36. protected function detail($id)
  37. {
  38. return Show::make($id, new Config(), function (Show $show) {
  39. $show->field('id');
  40. $show->field('key');
  41. $show->field('value');
  42. $show->field('desc');
  43. $show->field('created_at');
  44. $show->field('updated_at');
  45. });
  46. }
  47. /**
  48. * Make a form builder.
  49. *
  50. * @return Form
  51. */
  52. protected function form()
  53. {
  54. return Form::make(new Config(), function (Form $form) {
  55. $form->display('id');
  56. $form->image('value','推广背景图')->disk('oss')->autoUpload()->saving(function ($res) {
  57. return $res;
  58. })->required();
  59. $form->display('desc','标题');
  60. $form->disableViewButton();
  61. $form->disableDeleteButton();
  62. });
  63. }
  64. }