Merge pull request #14515 from squintfox/fixes-results-not-limited-by-api-params

Fixes #14289: /reports/activity API endpoint returns too many results due to orwhere
This commit is contained in:
snipe 2024-03-27 19:51:58 +00:00 committed by GitHub
commit cf8cb8521b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -32,13 +32,16 @@ class ReportsController extends Controller
} }
if (($request->filled('item_type')) && ($request->filled('item_id'))) { if (($request->filled('item_type')) && ($request->filled('item_id'))) {
$actionlogs = $actionlogs->where('item_id', '=', $request->input('item_id')) $actionlogs = $actionlogs->where(function($query) use ($request)
{
$query->where('item_id', '=', $request->input('item_id'))
->where('item_type', '=', 'App\\Models\\'.ucwords($request->input('item_type'))) ->where('item_type', '=', 'App\\Models\\'.ucwords($request->input('item_type')))
->orWhere(function($query) use ($request) ->orWhere(function($query) use ($request)
{ {
$query->where('target_id', '=', $request->input('item_id')) $query->where('target_id', '=', $request->input('item_id'))
->where('target_type', '=', 'App\\Models\\'.ucwords($request->input('item_type'))); ->where('target_type', '=', 'App\\Models\\'.ucwords($request->input('item_type')));
}); });
});
} }
if ($request->filled('action_type')) { if ($request->filled('action_type')) {