abstract:order('id','desc')->paginate(3); $this->view->productPic = $productPic; return $this->fetch(); } public function add(){ //查询所有产品 $product = ProductModel::all(); //将数据赋值炽模板 $this->view->product=$product; return $this->fetch(); } public function upload() { // 获取上传的图片信息 $file = Request::file('file'); // 验证图片信息并移动到指定目录 if ($info = $file->validate(['ext' => 'jpg,jpeg,png,gif'])->move('upload')) { // 拼接图片路径 $fileName = '/upload/' . $info->getSaveName(); // 返回成功信息 return json([1, '上传成功!', 'data' => $fileName]); } else { // 返回错误信息 return $file->getError(); } } public function DoAdd(){ $data = Request::param(); $data['time']=time(); $data['username']=Session::get('username'); $proPic = new ProductPicModel(); if($proPic->save($data)){ // 返回对应的数据 return ['res' => 1, 'msg' => '成功!']; } else { return ['res' => 0, 'msg' => '失败!']; } } public function del(){ $productId = Request::param('id'); $productPic = new ProductPicModel(); if($productPic->destroy($productId)){ return ['res'=>1,'msg'=>'删除成功!']; } } }
Correcting teacher:天蓬老师Correction time:2019-05-15 13:28:45
Teacher's summary:public function DoAdd(), 这种方法命名, 是极不规范的, 有空把开发手册再看看