编程语言
首页 > 编程语言> > thinkphp6 + 增删改查 +文件上传

thinkphp6 + 增删改查 +文件上传

作者:互联网

$params = $request->post();           $file = $request->file('images');         $fileName = \think\facade\Filesystem::disk('public')                   ->putFile( '/', $file);         $params['image'] = 'http://tps.com/storage/' . $fileName;
        $book = UserModel::where('title','=',$params['title'])             ->findOrEmpty();             if (!$book->isEmpty()){                 return json([                     'errorCode'=>'10001',                     'msg'=>'该图书已存在,请重新添加!',                 ]);             }             //添加图书               $result=(new UserModel())->save($params);               return json([                 'errorCode'=>'0',                 'msg'=>'创建成功',                 'result'=>$result             ]);    删除
    public function dele($id){         $result=UserModel::destroy($id);         if($result){             return '删除成功';         }     } 修改  public function upda($id){        $data=UserModel::where('id',$id)->select();       if($data){           return View::fetch('show/upda',compact('data'));       }     }   public function update($id){        $data=input();         $res=UserModel::update($data);         if($res){             return '修改成功';         }     }  状态修改 public function status(Request $request){        $id=$request['id'];        $status=$request['status'];        if($status==1){            $name['status']=0;        }else{            $name['status']=1;        }        $uname=UserModel::where('id',$id)->update($name);        if($uname){            return redirect('list');        }      
    }

标签:status,return,改查,thinkphp6,public,增删,UserModel,data,id
来源: https://www.cnblogs.com/ahao513/p/14802782.html