diff options
| author | grothedev <grothedev@gmail.com> | 2026-01-09 20:02:23 -0500 |
|---|---|---|
| committer | grothedev <grothedev@gmail.com> | 2026-01-09 20:02:23 -0500 |
| commit | a8446acd5a32f43534260cbe16225cfa975e18f2 (patch) | |
| tree | d0a42bd9cb319758db803878523187978458c157 /app/Http/Middleware | |
| parent | 57445d4ccbfe1cb190437c8f6b609fc83723b015 (diff) | |
Diffstat (limited to 'app/Http/Middleware')
| -rw-r--r-- | app/Http/Middleware/LogVisitors.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/app/Http/Middleware/LogVisitors.php b/app/Http/Middleware/LogVisitors.php new file mode 100644 index 0000000..bb95c8c --- /dev/null +++ b/app/Http/Middleware/LogVisitors.php @@ -0,0 +1,29 @@ +<?php + +namespace App\Http\Middleware; + +use Closure; +use Illuminate\Http\Request; +use Illuminate\Support\Facades\Log; +use Symfony\Component\HttpFoundation\Response; + +class LogVisitors +{ + /** + * Handle an incoming request. + * + * @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next + */ + public function handle(Request $request, Closure $next): Response + { + // Log visitor information to dedicated channel + Log::channel('visitors')->info('', [ + 'ip' => $request->ip(), + 'time' => now()->toDateTimeString(), + 'route' => $request->path(), + 'method' => $request->method(), + ]); + + return $next($request); + } +} |
