Files
CompanyProject/芳林公司项目/www.zhiyuanhelp.com/application/admin/service/LogService.php
2024-09-27 01:32:49 +08:00

38 lines
1.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* 日志服务
* Class LogService
* @package app\admin\service
*/
namespace app\admin\service;
use think\Db;
class LogService {
/**
* 登录日志
* @param $user_id 系统用户编号
* @param $type 登录类型 0退出1登录
* @param bool $status 状态0失败1成功
* @param string $remark
*/
public static function loginLog($user_id, $type = 1, $status = 1, $remark = '') {
$location_info = get_location();
$insert = [
'type' => $type,
'user_id' => $user_id,
'ip' => get_ip(),
'country' => $location_info['country'],
'region' => $location_info['region'],
'city' => $location_info['city'],
'isp' => $location_info['isp'],
'location' => $location_info['country'] . $location_info['region'] . $location_info['city'] . $location_info['isp'],
'remark' => $remark,
'status' => $status,
];
Db::name('SystemLoginRecord')->insert($insert);
}
}