diff --git a/app-modules/booking/src/Filament/Resources/Bookings/Tables/BookingsTable.php b/app-modules/booking/src/Filament/Resources/Bookings/Tables/BookingsTable.php index a1b3a7a..92036bc 100644 --- a/app-modules/booking/src/Filament/Resources/Bookings/Tables/BookingsTable.php +++ b/app-modules/booking/src/Filament/Resources/Bookings/Tables/BookingsTable.php @@ -28,9 +28,16 @@ class BookingsTable public static function configure(Table $table): Table { return $table - ->modifyQueryUsing(fn (Builder $query) => $query->with([ - 'route.company', 'route.fromDestination', 'route.toDestination', 'timeSlot', 'vehicleOptions', - ])) + ->modifyQueryUsing(fn (Builder $query) => $query + // A round trip's return leg is its own Booking row, but + // showing both legs side by side in one list reads as two + // unrelated bookings rather than one round trip — hide it + // here; it's still reachable via the primary leg's "Linked + // Leg" link on the detail page (view its own row directly). + ->where('is_return_leg', false) + ->with([ + 'route.company', 'route.fromDestination', 'route.toDestination', 'timeSlot', 'vehicleOptions', + ])) ->defaultSort('created_at', 'desc') ->columns([ TextColumn::make('booking_ref') diff --git a/app-modules/booking/tests/Feature/BookingResourceTest.php b/app-modules/booking/tests/Feature/BookingResourceTest.php index 83d99a6..199f1e3 100644 --- a/app-modules/booking/tests/Feature/BookingResourceTest.php +++ b/app-modules/booking/tests/Feature/BookingResourceTest.php @@ -344,6 +344,22 @@ test('a soft-deleted booking is hidden from the default list but visible via the ->assertCanSeeTableRecords([$active, $deleted]); }); +test('a round trip\'s return leg has no row of its own in the list, only its outbound leg', function () { + $outbound = Booking::factory()->create(['is_return_leg' => false]); + $return = Booking::factory()->create([ + 'is_return_leg' => true, + 'linked_booking_id' => $outbound->id, + ]); + $outbound->update(['linked_booking_id' => $return->id]); + + // Showing both legs as separate rows read as two unrelated bookings + // rather than one round trip — the return leg is still reachable via + // the outbound leg's "Linked Leg" link on the detail page. + Livewire::test(ListBookings::class) + ->assertCanSeeTableRecords([$outbound]) + ->assertCanNotSeeTableRecords([$return]); +}); + test('the restore action is only visible for a trashed booking', function () { $active = Booking::factory()->create(); $deleted = Booking::factory()->create();