33namespace Binafy \LaravelUserMonitoring \Middlewares ;
44
55use Binafy \LaravelUserMonitoring \Utills \Detector ;
6+ use Binafy \LaravelUserMonitoring \Utills \UserUtils ;
67use Closure ;
78use Illuminate \Http \Request ;
89use Illuminate \Support \Facades \DB ;
@@ -22,17 +23,17 @@ public function handle(Request $request, Closure $next): mixed
2223 }
2324
2425 $ detector = new Detector ();
25- $ guard = config ('user-monitoring.user.guard ' , 'web ' );
2626 $ exceptPages = config ('user-monitoring.visit_monitoring.except_pages ' , []);
2727
2828 if (empty ($ exceptPages ) || !$ this ->checkIsExceptPages ($ request ->path (), $ exceptPages )) {
2929 // Store visit
3030 DB ::table (config ('user-monitoring.visit_monitoring.table ' ))->insert ([
31- 'user_id ' => auth ( $ guard )-> id (),
31+ 'user_id ' => UserUtils:: getUserId (),
3232 'browser_name ' => $ detector ->getBrowser (),
3333 'platform ' => $ detector ->getDevice (),
3434 'device ' => $ detector ->getDevice (),
3535 'ip ' => $ request ->ip (),
36+ 'user_guard ' => UserUtils::getCurrentGuardName (),
3637 'page ' => $ request ->url (),
3738 'created_at ' => now (),
3839 'updated_at ' => now (),
@@ -45,7 +46,7 @@ public function handle(Request $request, Closure $next): mixed
4546 /**
4647 * Check request page are exists in expect pages.
4748 */
48- private function checkIsExceptPages (string $ page , array $ exceptPages ): bool
49+ protected function checkIsExceptPages (string $ page , array $ exceptPages ): bool
4950 {
5051 return collect ($ exceptPages )->contains ($ page );
5152 }
0 commit comments