|
@@ -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');
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|