Arhived fixed

This commit is contained in:
Simon Pocrnjič
2025-10-09 00:41:39 +02:00
parent 932bbdc294
commit 6108028942
2 changed files with 12 additions and 3 deletions
+10 -1
View File
@@ -208,7 +208,16 @@ protected function applyContextFilters(Builder $query, ?array $context, string $
if ($value === null) {
continue;
}
if (Schema::hasColumn($query->from, $key)) {
// Special precedence: for contracts table, if contract_id provided, always scope to that single id
if ($table === 'contracts' && $key === 'contract_id') {
$query->where('id', $value);
$applied = true;
// Do NOT allow broader filters (e.g., client_case_id) to widen the scope afterward
continue;
}
if (Schema::hasColumn($query->from, $key) && ! ($table === 'contracts' && $key === 'client_case_id' && isset($context['contract_id']))) {
// For contracts table: if contract_id present, skip client_case_id to avoid capturing all contracts of the case
$query->where($key, $value);
$applied = true;
}