增强:完善用户考勤记录机制,增加进出房间时间和登录次数统计
This commit is contained in:
@@ -121,6 +121,9 @@ class AuthController extends Controller
|
|||||||
{
|
{
|
||||||
Auth::login($user);
|
Auth::login($user);
|
||||||
|
|
||||||
|
// 递增访问次数
|
||||||
|
$user->increment('visit_num');
|
||||||
|
|
||||||
// 更新最后登录IP和时间
|
// 更新最后登录IP和时间
|
||||||
$user->update([
|
$user->update([
|
||||||
'last_ip' => $ip,
|
'last_ip' => $ip,
|
||||||
@@ -143,8 +146,11 @@ class AuthController extends Controller
|
|||||||
{
|
{
|
||||||
if (Auth::check()) {
|
if (Auth::check()) {
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
// 记录退出时间
|
// 记录退出时间和退出信息
|
||||||
$user->update(['out_time' => now()]);
|
$user->update([
|
||||||
|
'out_time' => now(),
|
||||||
|
'out_info' => '正常退出了聊天室',
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Auth::logout();
|
Auth::logout();
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ class ChatController extends Controller
|
|||||||
|
|
||||||
// 房间人气 +1(每次访问递增,复刻原版人气计数)
|
// 房间人气 +1(每次访问递增,复刻原版人气计数)
|
||||||
$room->increment('visit_num');
|
$room->increment('visit_num');
|
||||||
|
|
||||||
|
// 用户进房时间刷新
|
||||||
|
$user->update(['in_time' => now()]);
|
||||||
|
|
||||||
// 1. 将当前用户加入到 Redis 房间在线列表(包含 VIP 和管理员信息)
|
// 1. 将当前用户加入到 Redis 房间在线列表(包含 VIP 和管理员信息)
|
||||||
$superLevel = (int) Sysparam::getValue('superlevel', '100');
|
$superLevel = (int) Sysparam::getValue('superlevel', '100');
|
||||||
@@ -319,6 +322,12 @@ class ChatController extends Controller
|
|||||||
// 1. 从 Redis 删除该用户
|
// 1. 从 Redis 删除该用户
|
||||||
$this->chatState->userLeave($id, $user->username);
|
$this->chatState->userLeave($id, $user->username);
|
||||||
|
|
||||||
|
// 记录退出时间和退出信息
|
||||||
|
$user->update([
|
||||||
|
'out_time' => now(),
|
||||||
|
'out_info' => "正常退出了房间",
|
||||||
|
]);
|
||||||
|
|
||||||
// 2. 广播通知他人
|
// 2. 广播通知他人
|
||||||
broadcast(new UserLeft($id, $user->username))->toOthers();
|
broadcast(new UserLeft($id, $user->username))->toOthers();
|
||||||
|
|
||||||
@@ -356,7 +365,7 @@ class ChatController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function changeAvatar(Request $request): JsonResponse
|
public function changeAvatar(Request $request): JsonResponse
|
||||||
{
|
{
|
||||||
$user = auth()->user();
|
$user = Auth::user();
|
||||||
$headface = $request->input('headface', '');
|
$headface = $request->input('headface', '');
|
||||||
|
|
||||||
if (empty($headface)) {
|
if (empty($headface)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user