链街Dcat后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.7 KiB

  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Admin\Repositories\Banner;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Controllers\AdminController;
  8. use App\Models\ImsCjdcMarket as MarketModel;
  9. class BannerController extends AdminController
  10. {
  11. /**
  12. * Make a grid builder.
  13. *
  14. * @return Grid
  15. */
  16. protected function grid()
  17. {
  18. return Grid::make(new Banner(), function (Grid $grid) {
  19. $grid->column('id')->sortable();
  20. $grid->column('market_id');
  21. $grid->column('title');
  22. $grid->column('sub_title');
  23. $grid->column('cover')->image(50);
  24. $grid->column('cover_type');
  25. $grid->column('path');
  26. $grid->column('path_type');
  27. $grid->column('sort');
  28. $grid->column('status');
  29. $grid->column('type');
  30. $grid->column('created_at');
  31. $grid->column('updated_at')->sortable();
  32. $grid->filter(function (Grid\Filter $filter) {
  33. $filter->equal('id');
  34. });
  35. });
  36. }
  37. /**
  38. * Make a show builder.
  39. *
  40. * @param mixed $id
  41. *
  42. * @return Show
  43. */
  44. protected function detail($id)
  45. {
  46. return Show::make($id, new Banner(), function (Show $show) {
  47. $show->field('id');
  48. $show->field('market_id');
  49. $show->field('title');
  50. $show->field('sub_title');
  51. $show->field('cover');
  52. $show->field('cover_type');
  53. $show->field('path');
  54. $show->field('path_type');
  55. $show->field('sort');
  56. $show->field('status');
  57. $show->field('type');
  58. $show->field('created_at');
  59. $show->field('updated_at');
  60. });
  61. }
  62. /**
  63. * Make a form builder.
  64. *
  65. * @return Form
  66. */
  67. protected function form()
  68. {
  69. return Form::make(new Banner(), function (Form $form) {
  70. $form->display('id');
  71. // 市场
  72. $marketList = MarketModel::getMarket();
  73. $form->select('market_id')->width(4)->options($marketList);
  74. $form->text('title');
  75. $form->text('sub_title');
  76. $form->image('cover')->width(2);
  77. $form->select('cover_type')->options([1=>'图片', 2=>'视频']);
  78. $form->text('path');
  79. $form->select('path_type')->options(['page'=>'page','webview'=>'webview','applet'=>'applet']);
  80. $form->text('sort');
  81. $form->select('type')->options([1=>'首页banner']);
  82. $form->display('created_at');
  83. $form->display('updated_at');
  84. });
  85. }
  86. }