{{-- 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) --}}
| ID |
Section |
Amount |
Status |
Actions |
@foreach($allocations as $allocation)
| {{ $allocation->id }} |
{{ $allocation->section }} |
RM {{ $allocation->amount }} |
{{ $allocation->status }} |
|
@endforeach
{{-- CORRECT APPROACH 2: Using rowspan (only show actions on first row) --}}
| ID |
Section |
Amount |
Status |
Actions |
@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 --}}
| {{ $allocation->id }} |
{{ $allocation->section }} |
RM {{ $allocation->amount }} |
{{ $allocation->status }} |
|
@endif
{{-- Remaining rows: only show detail info --}}
{{ $detail->name ?? 'Detail' }} |
@endforeach
@endforeach
{{-- 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 --}}