<?php

namespace app\admin\controller;
use think\Controller;
use think\Db;
class  mlx extends Common
{
public function lst()
{
$list=Db::query("select * from modevtype ");
$this->assign('list',$list);
return $this->fetch();
}
public function add()
{
if (request()->isPost()){
$data = input('post.');
if(db('modevtype')->insert($data)){
return $this->success('ok','lst');
}
else {
return $this->error('false');
}
return ;
}
return $this->fetch();
}
public function edit(){
$id=input('id');
$mlxs=db('modevtype')->find($id);
if(request()->ispost()){
$data=[
'id'=>input('id'),
'mc'=>input('mc'),
];
$save=db('modevtype')->update($data);
if($save !== false){
$this->success('修改设备类型成功！','lst');
}else{
$this->error('修改设备类型失败！');
}
return;
}
$this->assign('mlxs',$mlxs);
return $this->fetch();
}
public function del(){
$id=input('id');
if(db('modevtype')->delete(input('id'))){
$this->success('删除设备类型成功！','lst');
}else{
$this->error('删除设备类型失败！');
}
}
public function logout(){
session(null);
$this->success('退出成功！','Login/index');
}
}
?>