Company.php 972 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace app\admin\controller;
  3. use think\Controller;
  4. use think\Db;
  5. class Company extends Controller{
  6. public function index(){
  7. if(request()->isAjax ()){
  8. $lists=Db::name("company")->select();
  9. return json(['code'=>220,'msg'=>'','count'=>1,'data'=>$lists]);
  10. }
  11. return $this->fetch("index");
  12. }
  13. public function edit()
  14. {
  15. if(request()->isPost()){
  16. //die;
  17. $data=input("text");
  18. $add=Db:: name("company")->where("cid",1)->update(["text"=>$data]);
  19. if($add){
  20. return json(["code" => 200,"msg" => "修改成功"]);
  21. }else{
  22. return json(["code" => 100,"msg" => "修改失败"]);
  23. }
  24. }
  25. $id=input("id");
  26. $data=Db::name("company")->where("cid",$id)->find();
  27. //halt($data);
  28. return $this->fetch("edit",["data"=>$data]);
  29. }
  30. }