<?php
namespace app\myadmin\controller;
use think\facade\Session;
use think\Db;
class Admin extends Base
{
public function index()
{
if($this->request->isPost()) {
$post = $this->request->post();
$res=Model("Admin")->index($post);
return $res;
} else {
return view();
}
}
public function edit()
{
$id = $this->request->has("id") ? $this->request->param("id", 0, "intval") : 0;
$info=Db::name("admin")->where("id",$id)->find();
$cateData=Db::name("cate")->select();
if($this->request->isPost()) {
$post = $this->request->post();
$res=Model("Admin")->edit($id,$post);
return $res;
} else {
return view("", [
"info"=>$info,
"cateData"=>$cateData
]);
}
}
public function myinfo()
{
if($this->request->isPost()) {
$post = $this->request->post();
$res=Model("Admin")->myedit($post);
return $res;
} else {
return view("", [
"info"=>Db::name("admin")->where("id",Session::get("adminId"))->find()
]);
}
}
public function del()
{
if($this->request->isPost()) {
$post = $this->request->post("id");
$res=DelTable($post,"admin");
return $res;
}
}
public function status()
{
if($this->request->isPost()) {
$post = $this->request->post();
$res=ChangeTable($post,"admin");
return $res;
}
}
}