Fix subcontract jobs not appearing in PDF

Load subcontractJobs via explicit query (bypassing TenantScope but
scoped manually by work_order_id + company_id) to avoid relation
caching issues. Pass as separate blade variable \$subcontractJobs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-09-06 12:29:55 +00:00
parent 2caac4ae8e
commit 221e311c08
2 changed files with 19 additions and 13 deletions
+3 -3
View File
@@ -252,7 +252,7 @@
</table>
@endif
@if ($wo->subcontractJobs->isNotEmpty())
@if ($subcontractJobs->isNotEmpty())
<h3 style="font-size: 12px; margin: 12px 0 4px; text-transform: uppercase; color: {{ $themeColor }};">{{ __('Lucrări terțe') }}</h3>
<table class="items">
<thead>
@@ -264,7 +264,7 @@
</tr>
</thead>
<tbody>
@foreach ($wo->subcontractJobs as $sj)
@foreach ($subcontractJobs as $sj)
<tr>
<td>{{ $sj->description ?? '—' }}</td>
<td>{{ $sj->subcontractor?->name ?? '—' }}</td>
@@ -276,7 +276,7 @@
<tfoot>
<tr>
<td colspan="3" class="r">{{ __('Subtotal terțe:') }}</td>
<td class="r">{{ number_format((float) $wo->subcontractJobs->sum('client_price'), 2, '.', ' ') }} {{ $currency }}</td>
<td class="r">{{ number_format((float) $subcontractJobs->sum('client_price'), 2, '.', ' ') }} {{ $currency }}</td>
</tr>
</tfoot>
</table>