Files
unified-restaurant-original/backend/app/Http/Middleware/LogEndpointHitMiddleware.php
2021-04-30 17:41:02 -04:00

26 lines
709 B
PHP

<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Log;
class LogEndpointHitMiddleware {
public function handle($request, Closure $next) {
$userId = $request->user ? $request->user->id : null;
$method = $request->getMethod();
$path = $request->getPathInfo();
Log::debug('User ' . $userId . ' hitting ' . $method . ' ' . $path . ' endpoint', [
'user' => $userId,
'method' => $method,
'path' => $path,
'input' => array_filter($request->input(), function ($key) {
return $key !== 'user';
}, ARRAY_FILTER_USE_KEY)
]);
return $next($request);
}
}