|
@@ -0,0 +1,103 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Admin\Controllers;
|
|
|
+
|
|
|
+use App\Admin\Repositories\BaseProductCategory;
|
|
|
+use App\Admin\Repositories\BaseVideo;
|
|
|
+use App\Admin\Repositories\BaseVideoCategory;
|
|
|
+use Dcat\Admin\Form;
|
|
|
+use Dcat\Admin\Grid;
|
|
|
+use Dcat\Admin\Show;
|
|
|
+use Dcat\Admin\Http\Controllers\AdminController;
|
|
|
+use Dcat\Admin\Layout\Content;
|
|
|
+
|
|
|
+class BaseVideoController extends AdminController
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * page index
|
|
|
+ */
|
|
|
+ public function index(Content $content)
|
|
|
+ {
|
|
|
+ return $content
|
|
|
+ ->header('Video Management')
|
|
|
+ ->description('all')
|
|
|
+ ->breadcrumb(['text'=>'Video Management','url'=>''])
|
|
|
+ ->body($this->grid());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Make a grid builder.
|
|
|
+ *
|
|
|
+ * @return Grid
|
|
|
+ */
|
|
|
+ protected function grid()
|
|
|
+ {
|
|
|
+ return Grid::make(new BaseVideo(), function (Grid $grid) {
|
|
|
+ $grid->column('id')->sortable();
|
|
|
+ $grid->column('title');
|
|
|
+ $grid->column('base_video_category.name','Category Name');
|
|
|
+ $grid->column('order')->orderable();
|
|
|
+ $grid->column('is_pinned')->switch();
|
|
|
+ $grid->column('enabled')->switch();
|
|
|
+ $grid->column('created_at');
|
|
|
+ $grid->column('updated_at')->sortable();
|
|
|
+ // 筛选
|
|
|
+ $grid->filter(function (Grid\Filter $filter) {
|
|
|
+ $filter->equal('sku');
|
|
|
+ $filter->like('title');
|
|
|
+ $filter->equal('category_id','Category')->select(BaseVideoCategory::selectOptions());
|
|
|
+ $filter->equal('enabled', 'enabled')->select([
|
|
|
+ 1 => 'Yes',
|
|
|
+ 0 => 'No',
|
|
|
+ ]);
|
|
|
+ });
|
|
|
+ //排序
|
|
|
+ // $grid->orderby->()->orderBy("order",'asc');
|
|
|
+ //按钮
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Make a show builder.
|
|
|
+ *
|
|
|
+ * @param mixed $id
|
|
|
+ *
|
|
|
+ * @return Show
|
|
|
+ */
|
|
|
+ protected function detail($id)
|
|
|
+ {
|
|
|
+ return Show::make($id, BaseVideo::with(['']), function (Show $show) {
|
|
|
+ $show->field('id');
|
|
|
+ $show->field('title');
|
|
|
+ $show->field('base_video_category.name','Category Name');
|
|
|
+ $show->field('remark');
|
|
|
+ $show->field('enabled')->using([
|
|
|
+ '0' => 'No', // 显示的状态名称
|
|
|
+ '1' => 'Yes',
|
|
|
+ ]);
|
|
|
+ $show->field('created_at');
|
|
|
+ $show->field('updated_at');
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Make a form builder.
|
|
|
+ *
|
|
|
+ * @return Form
|
|
|
+ */
|
|
|
+ protected function form()
|
|
|
+ {
|
|
|
+ return Form::make(new BaseVideo(), function (Form $form) {
|
|
|
+ $form->display('id');
|
|
|
+ $form->text('title')->required();
|
|
|
+ $form->select('category_id', 'Category Name')
|
|
|
+ ->options(BaseVideoCategory::selectOptions())
|
|
|
+ ->required();
|
|
|
+ $form->url("video_url")->required();
|
|
|
+ $form->editor('remark');
|
|
|
+ $form->switch('is_pinned')->default(0);
|
|
|
+ $form->switch('enabled')->default(1);
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|