Arhived fixed
This commit is contained in:
parent
932bbdc294
commit
6108028942
|
|
@ -1174,7 +1174,7 @@ public function show(ClientCase $clientCase)
|
||||||
}
|
}
|
||||||
|
|
||||||
return Inertia::render('Cases/Show', [
|
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,
|
'client_case' => $case,
|
||||||
'contracts' => $contracts,
|
'contracts' => $contracts,
|
||||||
'archive_meta' => [
|
'archive_meta' => [
|
||||||
|
|
@ -1343,7 +1343,7 @@ public function archiveContract(ClientCase $clientCase, string $uuid, Request $r
|
||||||
$overall = [];
|
$overall = [];
|
||||||
$hadAnyEffect = false;
|
$hadAnyEffect = false;
|
||||||
foreach ($settings as $setting) {
|
foreach ($settings as $setting) {
|
||||||
dd($setting);
|
|
||||||
$res = $executor->executeSetting($setting, $context, optional($request->user())->id);
|
$res = $executor->executeSetting($setting, $context, optional($request->user())->id);
|
||||||
foreach ($res as $table => $count) {
|
foreach ($res as $table => $count) {
|
||||||
$overall[$table] = ($overall[$table] ?? 0) + $count;
|
$overall[$table] = ($overall[$table] ?? 0) + $count;
|
||||||
|
|
|
||||||
|
|
@ -208,7 +208,16 @@ protected function applyContextFilters(Builder $query, ?array $context, string $
|
||||||
if ($value === null) {
|
if ($value === null) {
|
||||||
continue;
|
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);
|
$query->where($key, $value);
|
||||||
$applied = true;
|
$applied = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user