{{-- This is a guide for fixing Edit button visibility in package allocation tables --}} {{-- ISSUE: Edit buttons only show for first row (index 0) when using rowspan --}} {{-- SOLUTION: Add Edit/Copy/Delete buttons to EVERY row, or use rowspan consistently --}} {{-- CORRECT APPROACH 1: Edit button on each row (no rowspan) --}} @foreach($allocations as $allocation) @endforeach
ID Section Amount Status Actions
{{ $allocation->id }} {{ $allocation->section }} RM {{ $allocation->amount }} {{ $allocation->status }}
Edit
{{-- CORRECT APPROACH 2: Using rowspan (only show actions on first row) --}} @foreach($allocations as $index => $allocation) @php $details = $allocation->details ?? []; $detailCount = is_array($details) ? count($details) : (is_object($details) && method_exists($details, 'count') ? $details->count() : 1); @endphp @foreach($details as $detailIndex => $detail) @if($detailIndex === 0) {{-- First row: show ID and main info with rowspan --}} @endif {{-- Remaining rows: only show detail info --}} @endforeach @endforeach
ID Section Amount Status Actions
{{ $allocation->id }} {{ $allocation->section }} RM {{ $allocation->amount }} {{ $allocation->status }}
Edit
{{ $detail->name ?? 'Detail' }}
{{-- KEY POINTS: --}} {{-- 1. If using rowspan, ONLY the first row gets the action buttons with @if($detailIndex === 0) --}} {{-- 2. The rowspan attribute should equal the number of detail rows --}} {{-- 3. ALL rows with rowspan use @if($idx === 0) to show actions only once per group --}} {{-- 4. Make sure your controller passes the correct data structure --}}