<?php
namespace app\admin\model;
use think\Model;

// 引入框架内置类
use think\facade\Db;
use think\facade\Event;
use think\facade\Session;
use think\facade\Request;

class Log extends Model{
	
    // 定义时间戳字段名
    protected $createTime = 'create_time';
    protected $updateTime = 'update_time';
	
	
	//插入日志
    public static function insert($content){
		$data['admin']=Session::get('admin_id');
		$data['create_time']=time();
		$data['ip']=getRealIP();
		$data['content']=$content;
		Db::name('log')->insert($data);
    }
	
	//清空日志
    public static function delete_all(){
		Db::name('log')->delete(true);
		$sql = "alter table tq_log AUTO_INCREMENT=1";
		Db::query($sql);
    }
	
}