<?php
namespace app\api\model;
use think\Model;
class OperateLog extends Model
{
// 唯一键
protected $pk = 'id';
protected $table = 'operate_log';
public static function log($data)
{
return self::create($data, true);
}
}
model
<?php
namespace app\admin\model;
use app\common\controller\GetGuestInfoController;
use think\Model;
use think\Session;
class OperateLog extends Model
{
// 唯一键
protected $pk = 'id';
protected $table = 'operate_log';
public static function log($operate)
{
//$ip = $guestInfo->GetIP();
$ip = '120.xxx.xxx.159';
$info = getIpAddress($ip);
$email = Session::get('email');
$guestInfo = new GetGuestInfoController();
return self::create([
'ip' => $ip,
'address' => $info,
'email' => $email,
'operate' => $operate,
'operate_system' => $guestInfo->GetOS(),
'operate_browser' => $guestInfo->getBrowser()
], true);
}
}
使用
OperateLog::log('登录了后台');