Skip to content

Commit 75dcab5

Browse files
committed
add getUserId method to UserUtils
1 parent 19eee0a commit 75dcab5

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/Utills/UserUtils.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,20 @@ public static function getCurrentGuardName(): ?string
4747

4848
return null;
4949
}
50+
51+
/**
52+
* Get the user id by guards.
53+
*/
54+
public static function getUserId(): ?int
55+
{
56+
$guards = config('user-monitoring.user.guard', ['web']);
57+
58+
foreach ($guards as $guard) {
59+
if (Auth::guard($guard)->check()) {
60+
return Auth::guard($guard)->id();
61+
}
62+
}
63+
64+
return null;
65+
}
5066
}

0 commit comments

Comments
 (0)