DistVideoController.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. namespace App\Distributor\Controllers;
  3. use App\Distributor\Repositories\DistVideo;
  4. use Dcat\Admin\Form;
  5. use Dcat\Admin\Grid;
  6. use Dcat\Admin\Show;
  7. use Dcat\Admin\Http\Controllers\AdminController;
  8. use Dcat\Admin\Layout\Content;
  9. use Dcat\Admin\Admin;
  10. class DistVideoController extends AdminController
  11. {
  12. /**
  13. * page index
  14. */
  15. public function index(Content $content)
  16. {
  17. return $content
  18. ->view('distributor.layouts.content')
  19. ->header(admin_trans( 'admin.video_list'))
  20. ->description(admin_trans('admin.all'))
  21. ->breadcrumb(['text'=>'list','url'=>''])
  22. ->body($this->grid());
  23. }
  24. /**
  25. * Edit interface.
  26. *
  27. * @param mixed $id
  28. * @param Content $content
  29. * @return Content
  30. */
  31. public function edit($id, Content $content)
  32. {
  33. return $content
  34. ->view('distributor.layouts.content')
  35. ->translation($this->translation())
  36. ->title($this->title())
  37. ->description($this->description()['edit'] ?? trans('admin.edit'))
  38. ->body($this->form()->edit($id));
  39. }
  40. /**
  41. * Create interface.
  42. *
  43. * @param Content $content
  44. * @return Content
  45. */
  46. public function create(Content $content)
  47. {
  48. return $content
  49. ->view('distributor.layouts.content')
  50. ->translation($this->translation())
  51. ->title($this->title())
  52. ->description($this->description()['create'] ?? trans('admin.create'))
  53. ->body($this->form());
  54. }
  55. /**
  56. * Make a grid builder.
  57. *
  58. * @return Grid
  59. */
  60. protected function grid()
  61. {
  62. return Grid::make(new DistVideo(), function (Grid $grid) {
  63. $grid->column('id')->sortable();
  64. $grid->column('title');
  65. $grid->column('category_id');
  66. $grid->column('remark');
  67. $grid->column('enabled');
  68. $grid->column('order');
  69. $grid->column('video_url');
  70. $grid->column('is_pinned');
  71. $grid->column('created_at');
  72. $grid->column('updated_at')->sortable();
  73. $grid->filter(function (Grid\Filter $filter) {
  74. $filter->equal('id');
  75. });
  76. });
  77. }
  78. /**
  79. * Make a show builder.
  80. *
  81. * @param mixed $id
  82. *
  83. * @return Show
  84. */
  85. protected function detail($id)
  86. {
  87. return Show::make($id, new DistVideo(), function (Show $show) {
  88. $show->field('id');
  89. $show->field('title');
  90. $show->field('category_id');
  91. $show->field('remark');
  92. $show->field('enabled');
  93. $show->field('order');
  94. $show->field('video_url');
  95. $show->field('is_pinned');
  96. $show->field('created_at');
  97. $show->field('updated_at');
  98. });
  99. }
  100. /**
  101. * Make a form builder.
  102. *
  103. * @return Form
  104. */
  105. protected function form()
  106. {
  107. return Form::make(new DistVideo(), function (Form $form) {
  108. $form->display('id');
  109. $form->text('title');
  110. $form->text('category_id');
  111. $form->text('remark');
  112. $form->text('enabled');
  113. $form->text('order');
  114. $form->text('video_url');
  115. $form->text('is_pinned');
  116. $form->display('created_at');
  117. $form->display('updated_at');
  118. });
  119. }
  120. }