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