From 39aa9f566735b0cdaa06161bb49d27712ec8376f Mon Sep 17 00:00:00 2001 From: liapples Date: Wed, 18 Aug 2021 17:48:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BE=9B=E5=BA=94=E5=95=86=E7=9A=84=E4=BB=A3?= =?UTF-8?q?=E7=90=86=E5=95=86=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/AgentController.php | 111 ++++++++++++++++++ app/AdminSupplier/Repositories/Agent.php | 16 +++ app/AdminSupplier/routes.php | 1 + 3 files changed, 128 insertions(+) create mode 100644 app/AdminSupplier/Controllers/AgentController.php create mode 100644 app/AdminSupplier/Repositories/Agent.php diff --git a/app/AdminSupplier/Controllers/AgentController.php b/app/AdminSupplier/Controllers/AgentController.php new file mode 100644 index 0000000..9f15d85 --- /dev/null +++ b/app/AdminSupplier/Controllers/AgentController.php @@ -0,0 +1,111 @@ +where('status', ProductStatus::ON_SALE) + ->whereHas('product', function ($query) { + return $query->where(['supplier_id' => Admin::user()->id, 'status' => ProductStatus::ON_SALE]); + }); + }); + return Grid::make($model, function (Grid $grid) { + $grid->disableRowSelector(); + $grid->disableBatchDelete(); + $grid->disableCreateButton(); + $grid->disableActions(); + + $grid->column('id')->sortable(); + $grid->column('name'); + $grid->column('type')->using(AgentType::array()); + $grid->column('company_name'); + $grid->column('address'); + $grid->column('director'); + $grid->column('contact_phone'); + $grid->column('logo')->image(60, 60); + $grid->column('license_pic')->image(60, 60); + $grid->column('status')->using(UserStatus::array()); + $grid->column('created_at', '注册时间'); + + $grid->filter(function (Grid\Filter $filter) { + $filter->panel(); + + $filter->equal('id')->width(2); + $filter->like('name')->width(2); + $filter->like('company_name')->width(3); + $filter->equal('contact_phone')->width(2); + }); + }); + } + + /** + * Make a show builder. + * + * @param mixed $id + * + * @return Show + */ + protected function detail($id) + { + return Show::make($id, new Agent(), function (Show $show) { + $show->disableDeleteButton(); + $show->disableEditButton(); + + //目前逻辑是不允许供应商查看详情页,若需要打开详情页查看,需要再判断是不是当前供应商所属的代理商 + $show->field('id'); + /*$show->field('address'); + $show->field('avatar'); + $show->field('company_name'); + $show->field('contact_phone'); + $show->field('director'); + $show->field('license_pic'); + $show->field('logo'); + $show->field('name'); + $show->field('rate'); + $show->field('status'); + $show->field('type'); + $show->field('created_at'); + $show->field('updated_at');*/ + }); + } + + /** + * Make a form builder. + * + * @return Form + */ + protected function form() + { + return Form::make(new Agent(), function (Form $form) { + $form->disableFooter(); + $form->disableHeader(); + $form->disableDeleteButton(); + + $form->display('id'); + })->saving(function (Form $form) { + return $form->response()->error('禁止操作'); + })->deleting(function (Form $form) { + return $form->response()->error('禁止删除'); + }); + } +} diff --git a/app/AdminSupplier/Repositories/Agent.php b/app/AdminSupplier/Repositories/Agent.php new file mode 100644 index 0000000..d92b69f --- /dev/null +++ b/app/AdminSupplier/Repositories/Agent.php @@ -0,0 +1,16 @@ +resource('product/list', 'ProductController'); $router->resource('order/list', 'OrderController'); + $router->resource('agent/list', 'AgentController'); });