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

View File

@ -1174,7 +1174,7 @@ public function show(ClientCase $clientCase)
}
return Inertia::render('Cases/Show', [
'client' => $case->client()->with('person', fn ($q) => $q->with(['addresses', 'phones', 'emails','bankAccounts']))->firstOrFail(),
'client' => $case->client()->with('person', fn ($q) => $q->with(['addresses', 'phones', 'emails', 'bankAccounts']))->firstOrFail(),
'client_case' => $case,
'contracts' => $contracts,
'archive_meta' => [
@ -1343,7 +1343,7 @@ public function archiveContract(ClientCase $clientCase, string $uuid, Request $r
$overall = [];
$hadAnyEffect = false;
foreach ($settings as $setting) {
dd($setting);
$res = $executor->executeSetting($setting, $context, optional($request->user())->id);
foreach ($res as $table => $count) {
$overall[$table] = ($overall[$table] ?? 0) + $count;

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;
}