12345678910111213141516171819202122232425262728293031 |
- <?php
- namespace app\admin\controller;
- use think\Controller;
- use think\Db;
- class Company extends Controller{
- public function index(){
- if(request()->isAjax ()){
- $lists=Db::name("company")->select();
- return json(['code'=>220,'msg'=>'','count'=>1,'data'=>$lists]);
- }
- return $this->fetch("index");
- }
- public function edit()
- {
- if(request()->isPost()){
- //die;
- $data=input("text");
- $add=Db:: name("company")->where("cid",1)->update(["text"=>$data]);
- if($add){
- return json(["code" => 200,"msg" => "修改成功"]);
- }else{
- return json(["code" => 100,"msg" => "修改失败"]);
- }
- }
- $id=input("id");
- $data=Db::name("company")->where("cid",$id)->find();
- //halt($data);
- return $this->fetch("edit",["data"=>$data]);
- }
- }
|