\App\ModelsLogUserLogin

用户登录日志

职责:登录认证全生命周期(成功/失败/登出/被踢下线)的审计记录载体; 登录成功插行、登出与被踢回填原会话行 logout_time,写路径仅 WriteUserLoginLog。

Summary

Methods
Properties
Constants
timestampCasts()
$timestamps
$id
$user_id
$user_name
$login_type
$login_status
$fail_reason
$client_ip
$ip_location
$browser
$os
$user_agent
$server_ip
$instance_id
$trace_id
$session_id
$login_time
$logout_time
$extra
LOGIN_STATUS_FAILED
LOGIN_STATUS_SUCCESS
LOGIN_STATUS_KICKED
LOGIN_TYPE_PASSWORD
serializeDate()
casts()
$table
$hidden
$fillable
N/A
No private methods found
No private properties found
N/A

Constants

LOGIN_STATUS_FAILED

LOGIN_STATUS_FAILED = 0

登录状态:失败

LOGIN_STATUS_SUCCESS

LOGIN_STATUS_SUCCESS = 1

登录状态:成功

LOGIN_STATUS_KICKED

LOGIN_STATUS_KICKED = 2

登录状态:被踢下线

LOGIN_TYPE_PASSWORD

LOGIN_TYPE_PASSWORD = 0

登录方式:密码

Properties

$timestamps

$timestamps

$id

$id : int

主键ID

Type

int

$user_id

$user_id : int|null

用户ID(登录失败且用户不存在时为空)

Type

int|null

$user_name

$user_name : string

用户名

Type

string

$login_type

$login_type : int

登录方式:0 密码,1 短信,2 OAuth,3 扫码

Type

int

$login_status

$login_status : int

登录状态:0 失败,1 成功,2 被踢下线

Type

int

$fail_reason

$fail_reason : string

失败原因

Type

string

$client_ip

$client_ip : string

客户端 IP

Type

string

$ip_location

$ip_location : string

IP 归属地

Type

string

$browser

$browser : string

浏览器

Type

string

$os

$os : string

操作系统

Type

string

$user_agent

$user_agent : string

User-Agent

Type

string

$server_ip

$server_ip : string

服务器 IP

Type

string

$instance_id

$instance_id : string

实例标识

Type

string

$trace_id

$trace_id : string|null

链路追踪 ID

Type

string|null

$session_id

$session_id : string|null

会话指纹(token_id 的 SHA-256 派生,防泄露劫持;原始值禁止入日志)

Type

string|null

$login_time

$login_time : string

登录时间

Type

string

$logout_time

$logout_time : string|null

登出时间

Type

string|null

$extra

$extra : array|null

扩展信息

┌────────────────── 分区导航(按此顺序阅读)──────────────────┐ 分区 1 · 常量 登录状态 LOGIN_STATUS_* / 登录方式 LOGIN_TYPE_* 分区 2 · 表名与属性 $table / $fillable / casts └────────────────────────────────────────────────────────────┘

Type

array|null

$table

$table

$hidden

$hidden

$fillable

$fillable

Methods

timestampCasts()

timestampCasts() : array<string,string>

全库统一的时间列 cast 段(单源:约 22 个模型 casts() 内重复的两行)。 使用方模型 casts() 内 `return array_merge(self::timestampCasts(), [...])`。

Returns

array

serializeDate()

serializeDate(\DateTimeInterface  $date) : string

所有日期属性统一按 "年-月-日 时:分:秒" 序列化。

Parameters

\DateTimeInterface $date

Returns

string —

casts()

casts() : array

Returns

array —