| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace app\admin\controller;
- use app\BaseController;
- use app\common\model\ProductCategoryModel;
- use app\common\model\ProductModel;
- use think\App;
- use think\facade\View;
- use think\Request;
- class Product extends BaseController
- {
- private $productModel;
- private $categoryModel;
- public function __construct(App $app)
- {
- parent::__construct($app);
- $this->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();
- }
- }
|