فهرست منبع

feat:dist 添加初始控制器

igb 5 ماه پیش
والد
کامیت
d458d2518b

+ 159 - 0
app/Distributor/Controllers/AdminController.php

@@ -0,0 +1,159 @@
+<?php
+
+namespace App\Distributor\controllers;
+
+use App\Distributor\Layout\Content;
+use Illuminate\Routing\Controller;
+
+class AdminController extends Controller
+{
+    /**
+     * Title for current resource.
+     *
+     * @var string
+     */
+    protected $title;
+
+    /**
+     * Set description for following 4 action pages.
+     *
+     * @var array
+     */
+    protected $description = [
+        //        'index'  => 'Index',
+        //        'show'   => 'Show',
+        //        'edit'   => 'Edit',
+        //        'create' => 'Create',
+    ];
+
+    /**
+     * Set translation path.
+     *
+     * @var string
+     */
+    protected $translation;
+
+    /**
+     * Get content title.
+     *
+     * @return string
+     */
+    protected function title()
+    {
+        return $this->title ?: admin_trans_label();
+    }
+
+    /**
+     * Get description for following 4 action pages.
+     *
+     * @return array
+     */
+    protected function description()
+    {
+        return $this->description;
+    }
+
+    /**
+     * Get translation path.
+     *
+     * @return string
+     */
+    protected function translation()
+    {
+        return $this->translation;
+    }
+
+    /**
+     * Index interface.
+     *
+     * @param  Content  $content
+     * @return Content
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->translation($this->translation())
+            ->title($this->title())
+            ->description($this->description()['index'] ?? trans('admin.list'))
+            ->body($this->grid());
+    }
+
+    /**
+     * Show interface.
+     *
+     * @param  mixed  $id
+     * @param  Content  $content
+     * @return Content
+     */
+    public function show($id, Content $content)
+    {
+        return $content
+            ->translation($this->translation())
+            ->title($this->title())
+            ->description($this->description()['show'] ?? trans('admin.show'))
+            ->body($this->detail($id));
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param  mixed  $id
+     * @param  Content  $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->translation($this->translation())
+            ->title($this->title())
+            ->description($this->description()['edit'] ?? trans('admin.edit'))
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param  Content  $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->translation($this->translation())
+            ->title($this->title())
+            ->description($this->description()['create'] ?? trans('admin.create'))
+            ->body($this->form());
+    }
+
+    /**
+     * Update the specified resource in storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function update($id)
+    {
+        return $this->form()->update($id);
+    }
+
+    /**
+     * Store a newly created resource in storage.
+     *
+     * @return mixed
+     */
+    public function store()
+    {
+        return $this->form()->store();
+    }
+
+    /**
+     * Remove the specified resource from storage.
+     *
+     * @param  int  $id
+     * @return \Illuminate\Http\Response
+     */
+    public function destroy($id)
+    {
+        return $this->form()->destroy($id);
+    }
+}

+ 1 - 0
app/Distributor/Controllers/AuthController.php

@@ -24,6 +24,7 @@ class AuthController extends BaseAuthController
         );
 
         return $content
+            ->view('distributor.layouts.content')
             ->title(trans('admin.user_setting'))
             ->body($form->edit(Admin::user()->getKey()));
 

+ 127 - 0
app/Distributor/Controllers/DistProductCategoryController.php

@@ -0,0 +1,127 @@
+<?php
+
+namespace App\Distributor\Controllers;
+
+use App\Distributor\Repositories\DistProductCategory;
+use Dcat\Admin\Form;
+use Dcat\Admin\Grid;
+use Dcat\Admin\Show;
+use Dcat\Admin\Http\Controllers\AdminController;
+use Dcat\Admin\Layout\Content;
+use Dcat\Admin\Admin;
+
+class DistProductCategoryController extends AdminController
+{
+    /**
+     * page index
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->view('distributor.layouts.content')
+            ->header(admin_trans('admin.proudct_category'))
+            ->description(admin_trans('admin.all'))
+            ->breadcrumb(['text'=>'list','url'=>''])
+            ->body($this->grid());
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param  mixed  $id
+     * @param  Content  $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->view('distributor.layouts.content')
+            ->translation($this->translation())
+            ->title($this->title())
+            ->description($this->description()['edit'] ?? trans('admin.edit'))
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param  Content  $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->view('distributor.layouts.content')
+            ->translation($this->translation())
+            ->title($this->title())
+            ->description($this->description()['create'] ?? trans('admin.create'))
+            ->body($this->form());
+    }
+
+
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        return Grid::make(new DistProductCategory(), function (Grid $grid) {
+            $grid->column('id')->sortable();
+            $grid->column('name');
+            $grid->column('parent_id');
+            $grid->column('order');
+            $grid->column('enabled');
+            $grid->column('parameter_id');
+            $grid->column('created_at');
+            $grid->column('updated_at')->sortable();
+
+            $grid->filter(function (Grid\Filter $filter) {
+                $filter->equal('id');
+
+            });
+        });
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     *
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        return Show::make($id, new DistProductCategory(), function (Show $show) {
+            $show->field('id');
+            $show->field('name');
+            $show->field('parent_id');
+            $show->field('order');
+            $show->field('enabled');
+            $show->field('parameter_id');
+            $show->field('created_at');
+            $show->field('updated_at');
+        });
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        return Form::make(new DistProductCategory(), function (Form $form) {
+            $form->display('id');
+            $form->text('name');
+            $form->text('parent_id');
+            $form->text('order');
+            $form->text('enabled');
+            $form->text('parameter_id');
+
+            $form->display('created_at');
+            $form->display('updated_at');
+        });
+    }
+}

+ 142 - 0
app/Distributor/Controllers/DistProductController.php

@@ -0,0 +1,142 @@
+<?php
+
+namespace App\Distributor\Controllers;
+
+use App\Distributor\Repositories\DistProduct;
+use Dcat\Admin\Form;
+use Dcat\Admin\Grid;
+use Dcat\Admin\Show;
+use Dcat\Admin\Http\Controllers\AdminController;
+use Dcat\Admin\Layout\Content;
+use Dcat\Admin\Admin;
+
+class DistProductController extends AdminController
+{
+    /**
+     * page index
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->view('distributor.layouts.content')
+            ->header(admin_trans( 'admin.products_list'))
+            ->description(admin_trans('admin.all'))
+            ->breadcrumb(['text'=>'list','url'=>''])
+            ->body($this->grid());
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param  mixed  $id
+     * @param  Content  $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->view('distributor.layouts.content')
+            ->translation($this->translation())
+            ->title($this->title())
+            ->description($this->description()['edit'] ?? trans('admin.edit'))
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param  Content  $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->view('distributor.layouts.content')
+            ->translation($this->translation())
+            ->title($this->title())
+            ->description($this->description()['create'] ?? trans('admin.create'))
+            ->body($this->form());
+    }
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        return Grid::make(new DistProduct(), function (Grid $grid) {
+            $grid->column('id')->sortable();
+            $grid->column('title');
+            $grid->column('keywords');
+            $grid->column('description');
+            $grid->column('sku');
+            $grid->column('category_id');
+            $grid->column('issuance_date');
+            $grid->column('order');
+            $grid->column('enabled');
+            $grid->column('content');
+            $grid->column('parameters');
+            $grid->column('is_pinned');
+            $grid->column('created_at');
+            $grid->column('updated_at')->sortable();
+
+            $grid->filter(function (Grid\Filter $filter) {
+                $filter->equal('id');
+
+            });
+        });
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     *
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        return Show::make($id, new DistProduct(), function (Show $show) {
+            $show->field('id');
+            $show->field('title');
+            $show->field('keywords');
+            $show->field('description');
+            $show->field('sku');
+            $show->field('category_id');
+            $show->field('issuance_date');
+            $show->field('order');
+            $show->field('enabled');
+            $show->field('content');
+            $show->field('parameters');
+            $show->field('is_pinned');
+            $show->field('created_at');
+            $show->field('updated_at');
+        });
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        return Form::make(new DistProduct(), function (Form $form) {
+            $form->display('id');
+            $form->text('title');
+            $form->text('keywords');
+            $form->text('description');
+            $form->text('sku');
+            $form->text('category_id');
+            $form->text('issuance_date');
+            $form->text('order');
+            $form->text('enabled');
+            $form->text('content');
+            $form->text('parameters');
+            $form->text('is_pinned');
+
+            $form->display('created_at');
+            $form->display('updated_at');
+        });
+    }
+}

+ 122 - 0
app/Distributor/Controllers/DistProductParameterController.php

@@ -0,0 +1,122 @@
+<?php
+
+namespace App\Distributor\Controllers;
+
+use App\Distributor\Repositories\DistProductParameter;
+use Dcat\Admin\Form;
+use Dcat\Admin\Grid;
+use Dcat\Admin\Show;
+use Dcat\Admin\Http\Controllers\AdminController;
+use Dcat\Admin\Layout\Content;
+use Dcat\Admin\Admin;
+
+class DistProductParameterController extends AdminController
+{
+    /**
+     * page index
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->view('distributor.layouts.content')
+            ->header(admin_trans( 'admin.product_parameter'))
+            ->description(admin_trans('admin.all'))
+            ->breadcrumb(['text'=>'list','url'=>''])
+            ->body($this->grid());
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param  mixed  $id
+     * @param  Content  $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->view('distributor.layouts.content')
+            ->translation($this->translation())
+            ->title($this->title())
+            ->description($this->description()['edit'] ?? trans('admin.edit'))
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param  Content  $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->view('distributor.layouts.content')
+            ->translation($this->translation())
+            ->title($this->title())
+            ->description($this->description()['create'] ?? trans('admin.create'))
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        return Grid::make(new DistProductParameter(), function (Grid $grid) {
+            $grid->column('id')->sortable();
+            $grid->column('name');
+            $grid->column('order');
+            $grid->column('enabled');
+            $grid->column('content');
+            $grid->column('created_at');
+            $grid->column('updated_at')->sortable();
+
+            $grid->filter(function (Grid\Filter $filter) {
+                $filter->equal('id');
+
+            });
+        });
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     *
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        return Show::make($id, new DistProductParameter(), function (Show $show) {
+            $show->field('id');
+            $show->field('name');
+            $show->field('order');
+            $show->field('enabled');
+            $show->field('content');
+            $show->field('created_at');
+            $show->field('updated_at');
+        });
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        return Form::make(new DistProductParameter(), function (Form $form) {
+            $form->display('id');
+            $form->text('name');
+            $form->text('order');
+            $form->text('enabled');
+            $form->text('content');
+
+            $form->display('created_at');
+            $form->display('updated_at');
+        });
+    }
+}

+ 122 - 0
app/Distributor/Controllers/DistVideoCategoryController.php

@@ -0,0 +1,122 @@
+<?php
+
+namespace App\Distributor\Controllers;
+
+use App\Distributor\Repositories\DistVideoCategory;
+use Dcat\Admin\Form;
+use Dcat\Admin\Grid;
+use Dcat\Admin\Show;
+use Dcat\Admin\Http\Controllers\AdminController;
+use Dcat\Admin\Layout\Content;
+use Dcat\Admin\Admin;
+
+class DistVideoCategoryController extends AdminController
+{
+    /**
+     * page index
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->view('distributor.layouts.content')
+            ->header(admin_trans( 'admin.video_category'))
+            ->description(admin_trans('admin.all'))
+            ->breadcrumb(['text'=>'list','url'=>''])
+            ->body($this->grid());
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param  mixed  $id
+     * @param  Content  $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->view('distributor.layouts.content')
+            ->translation($this->translation())
+            ->title($this->title())
+            ->description($this->description()['edit'] ?? trans('admin.edit'))
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param  Content  $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->view('distributor.layouts.content')
+            ->translation($this->translation())
+            ->title($this->title())
+            ->description($this->description()['create'] ?? trans('admin.create'))
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        return Grid::make(new DistVideoCategory(), function (Grid $grid) {
+            $grid->column('id')->sortable();
+            $grid->column('name');
+            $grid->column('parent_id');
+            $grid->column('order');
+            $grid->column('enabled');
+            $grid->column('created_at');
+            $grid->column('updated_at')->sortable();
+
+            $grid->filter(function (Grid\Filter $filter) {
+                $filter->equal('id');
+
+            });
+        });
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     *
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        return Show::make($id, new DistVideoCategory(), function (Show $show) {
+            $show->field('id');
+            $show->field('name');
+            $show->field('parent_id');
+            $show->field('order');
+            $show->field('enabled');
+            $show->field('created_at');
+            $show->field('updated_at');
+        });
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        return Form::make(new DistVideoCategory(), function (Form $form) {
+            $form->display('id');
+            $form->text('name');
+            $form->text('parent_id');
+            $form->text('order');
+            $form->text('enabled');
+
+            $form->display('created_at');
+            $form->display('updated_at');
+        });
+    }
+}

+ 131 - 0
app/Distributor/Controllers/DistVideoController.php

@@ -0,0 +1,131 @@
+<?php
+
+namespace App\Distributor\Controllers;
+
+use App\Distributor\Repositories\DistVideo;
+use Dcat\Admin\Form;
+use Dcat\Admin\Grid;
+use Dcat\Admin\Show;
+use Dcat\Admin\Http\Controllers\AdminController;
+use Dcat\Admin\Layout\Content;
+use Dcat\Admin\Admin;
+
+class DistVideoController extends AdminController
+{
+    /**
+     * page index
+     */
+    public function index(Content $content)
+    {
+        return $content
+            ->view('distributor.layouts.content')
+            ->header(admin_trans( 'admin.video_list'))
+            ->description(admin_trans('admin.all'))
+            ->breadcrumb(['text'=>'list','url'=>''])
+            ->body($this->grid());
+    }
+
+    /**
+     * Edit interface.
+     *
+     * @param  mixed  $id
+     * @param  Content  $content
+     * @return Content
+     */
+    public function edit($id, Content $content)
+    {
+        return $content
+            ->view('distributor.layouts.content')
+            ->translation($this->translation())
+            ->title($this->title())
+            ->description($this->description()['edit'] ?? trans('admin.edit'))
+            ->body($this->form()->edit($id));
+    }
+
+    /**
+     * Create interface.
+     *
+     * @param  Content  $content
+     * @return Content
+     */
+    public function create(Content $content)
+    {
+        return $content
+            ->view('distributor.layouts.content')
+            ->translation($this->translation())
+            ->title($this->title())
+            ->description($this->description()['create'] ?? trans('admin.create'))
+            ->body($this->form());
+    }
+
+    /**
+     * Make a grid builder.
+     *
+     * @return Grid
+     */
+    protected function grid()
+    {
+        return Grid::make(new DistVideo(), function (Grid $grid) {
+            $grid->column('id')->sortable();
+            $grid->column('title');
+            $grid->column('category_id');
+            $grid->column('remark');
+            $grid->column('enabled');
+            $grid->column('order');
+            $grid->column('video_url');
+            $grid->column('is_pinned');
+            $grid->column('created_at');
+            $grid->column('updated_at')->sortable();
+
+            $grid->filter(function (Grid\Filter $filter) {
+                $filter->equal('id');
+
+            });
+        });
+    }
+
+    /**
+     * Make a show builder.
+     *
+     * @param mixed $id
+     *
+     * @return Show
+     */
+    protected function detail($id)
+    {
+        return Show::make($id, new DistVideo(), function (Show $show) {
+            $show->field('id');
+            $show->field('title');
+            $show->field('category_id');
+            $show->field('remark');
+            $show->field('enabled');
+            $show->field('order');
+            $show->field('video_url');
+            $show->field('is_pinned');
+            $show->field('created_at');
+            $show->field('updated_at');
+        });
+    }
+
+    /**
+     * Make a form builder.
+     *
+     * @return Form
+     */
+    protected function form()
+    {
+        return Form::make(new DistVideo(), function (Form $form) {
+            $form->display('id');
+            $form->text('title');
+            $form->text('category_id');
+            $form->text('remark');
+            $form->text('enabled');
+            $form->text('order');
+            $form->text('video_url');
+            $form->text('is_pinned');
+
+            $form->display('created_at');
+            $form->display('updated_at');
+        });
+    }
+}