init
This commit is contained in:
61
app/admin/controller/Agent.php
Executable file
61
app/admin/controller/Agent.php
Executable file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: ORICO
|
||||
* Date: 2019-01-15
|
||||
* Time: 11:01
|
||||
*/
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use think\Lang;
|
||||
use think\Loader;
|
||||
use think\Config;
|
||||
|
||||
class Agent extends BaseController
|
||||
{
|
||||
public function index(){
|
||||
$agent = Db('agent');
|
||||
$where = ['stat'=>0];
|
||||
$list = $agent->where($where)->select();
|
||||
$count = count($list);
|
||||
$list = $agent->where($where)->paginate(20,$count);
|
||||
$page = $list->render();
|
||||
//dump($page);die;
|
||||
$this->assign('page',$page);
|
||||
$this->assign('list',$list);;
|
||||
return $this->fetch();
|
||||
|
||||
}
|
||||
public function add(){
|
||||
return $this->fetch();
|
||||
}
|
||||
public function creat(){
|
||||
$data = $_POST;
|
||||
$data['stat'] = 0;
|
||||
$adent = Db('agent');
|
||||
$inster = $adent->insert($data);
|
||||
if($inster){
|
||||
return $this->success('添加成功');
|
||||
}else{
|
||||
return $this->error('添加失败');
|
||||
}
|
||||
}
|
||||
public function edit(){
|
||||
$where = ['id '=>$_GET['id'],'stat'=>0];
|
||||
$agent = Db('agent');
|
||||
$data = $agent->where($where)->find();
|
||||
$this->assign('data',$data);
|
||||
return $this->fetch();
|
||||
}
|
||||
public function save(){
|
||||
$data = $_POST;
|
||||
$adent = Db('agent');
|
||||
$inster = $adent->insert($data);
|
||||
if($inster){
|
||||
return $this->success('修改成功');
|
||||
}else{
|
||||
return $this->error('修改失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user