1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- namespace app\admin\controller;
- use app\common\controller\Backend;
- use think\facade\Config;
- use think\facade\Request;
- use app\admin\model\AdminLog as LogModel;
- use think\facade\View;
- class Adminlog extends Backend {
- public function initialize()
- {
- parent::initialize();
- }
-
- public function index(){
- if(Request::isPost()){
- $keys=Request::post('keys','','trim');
- $page = Request::post('page')?Request::post('page'):1;
- $list = LogModel::where('status',1)
- ->where('username|log_title','like','%'.$keys.'%')
- ->order('id desc')
- ->paginate(array('list_rows'=> $this->pageSize,'page'=>$page))
- ->toArray();
- if(!empty($list['data'])){
- foreach ($list['data'] as $k => $v) {
- $useragent = explode('(', $v['log_agent']);
- $list['data'][$k]['log_agent'] = $useragent[0];
- }
- }
- $result = ['code'=>0,'msg'=>lang('get info success'),'data'=>$list['data'],'count'=>$list['total']];
- return $result;
- }
- return View::fetch();
- }
-
- public function delete(){
- $id = Request::post('id');
- if(!$id){
- $this->error(lang('id is not exist'));
- }
- if(!is_array($id)){
- $id = [$id];
- }
- if(LogModel::destroy($id)){
- $this->success(lang('delete success'));
- }else{
- $this->error(lang('delete fail'));
- }
- }
- }
|