-
app/Http/Controllers/API/RequestsController.php
Open in GitHubuse App\Http\Controllers\Controller; use App\Http\Resources\RequestCollection; use OpenDialogAi\Core\RequestLog; class RequestsController extends Controller { // public function index(Request $request) { $query = RequestLog::orderByDesc('microtime')->with('responseLog'); if ($request->url) { $query->where('url', 'like', '%' . $request->url . '%'); } if ($request->source_ip) { $query->where('source_ip', $request->source_ip); } if ($request->user_id) { $query->where('user_id', 'like', '%' . $request->user_id . '%'); } if ($request->http_status) { $http_status = $request->http_status; $query->whereHas('responseLog', function ($query) use ($http_status) { $query->where('http_status', $http_status); }); } $requestLogs = $query->paginate(50); return new RequestCollection($requestLogs); } // }