productModel = new ProductModel(); $this->categoryModel = new ProductCategoryModel(); } /** * @param Request $request * @return \think\response\View * @throws \think\db\exception\DbException */ public function index(Request $request) { $params = $request->param(); $format_params = [ 'bar_code' => format_string($params['bar_code'] ?? null), 'category_id' => format_string($params['category_id'] ?? null), 'is_serve' => format_string($params['is_serve'] ?? null), ]; View::assign([ 'list' => $this->productModel->findByPaginate($format_params), 'params' => $format_params, 'all_category' => recursion($this->categoryModel->findAll(),0), ]); return view(); } public function add(Request $request) { return view(); } public function edit(Request $request) { return view(); } public function delete(Request $request) { $params = $request->param(); if(!isset($params['ids'])) return $this->fail(lang("Please select the data you want to delete")); $this->productModel->deleteByIds(explode(',',$params['ids'])); return $this->ok(); } }