12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2020-09-22
- * Time: 17:11
- */
-
- namespace app\back\controller;
-
-
- use app\back\model\GoodsCategoryModel;
- use cmf\controller\AdminBaseController;
- use app\back\model\GoodsSearchModel;
- class GoodsSearchController extends AdminBaseController
- {
- public function index()
- {
- $GoodsSearchModel = new GoodsSearchModel();
- $list = $GoodsSearchModel::with('category')->select();
- $this->assign('list',$list);
- return $this->fetch();
- }
- public function add()
- {
- $GoodsCategoryModel = new GoodsCategoryModel();
- $list = $GoodsCategoryModel::where('is_show',1)->select();
- $this->assign('list',$list);
- return $this->fetch();
- }
-
- public function addPost()
- {
- $data = $this->request->param();
- $GoodsSearchModel = new GoodsSearchModel();
- $GoodsSearchModel->allowField(true)->isUpdate(false)->save($data);
- $this->success('添加成功');
- }
- public function edit()
- {
- $id = $this->request->param('id');
- $info = GoodsSearchModel::get($id);
- $info->category;
- $GoodsCategoryModel = new GoodsCategoryModel();
- $list = $GoodsCategoryModel::where('is_show',1)->where('id','<>',$info->category_id)->select();
- $this->assign('list',$list);
- $this->assign('info',$info);
- return $this->fetch();
- }
- public function editPost()
- {
- $data = $this->request->param();
- $GoodsSearchModel = new GoodsSearchModel();
- $GoodsSearchModel->allowField(true)->isUpdate(true)->save($data,['id'=>$data]);
- $this->success('编辑成功');
- }
- public function delete()
- {
- $id = $this->request->param('id');
- GoodsSearchModel::where('id',$id)->delete();
- $this->success('删除成功');
- }
-
- }
|