@php use App\Models\Panelresult; use App\Models\Samplehead; use App\Filament\Resources\SampleheadResource; // Get the current samplehead and panel $currentSamplehead = Samplehead::find($samplehead_id); $currentPanel = \App\Models\Pcrpanel::find($current_panel_id); // Get all sampleheads that have results for this panel type AND belong to the same plant // Exclude the current samplehead from the list $sampleheads = Panelresult::where('pcrpanel_id', $current_panel_id) ->whereHas('samplehead', function($query) use ($currentSamplehead, $samplehead_id) { $query->where('plant_id', $currentSamplehead->plant_id) ->where('id', '!=', $samplehead_id); }) ->select('samplehead_id', 'result_nr') ->distinct() ->with(['samplehead' => function($query) { $query->orderBy('sample_analyzed_date', 'desc'); }]) ->get() ->pluck('samplehead') ->filter() ->unique('id') ->sortByDesc('sample_analyzed_date'); @endphp
Vorherige Proben:
@if($sampleheads->isEmpty())
Keine vorherigen Proben verfügbar
@else
@foreach($sampleheads as $samplehead) @endforeach
Probe Datum Aktionen
{{ $samplehead->sample_nr }} {{ $samplehead->sample_analyzed_date ? \Carbon\Carbon::parse($samplehead->sample_analyzed_date)->format('d.m.Y') : '-' }}
@endif