modify booking response data
This commit is contained in:
@@ -15,6 +15,7 @@ use Modules\Booking\Enums\BookingChannel;
|
||||
use Modules\Booking\Http\Requests\StoreBookingRequest;
|
||||
use Modules\Booking\Http\Resources\BookingResource;
|
||||
use Modules\Booking\Models\Booking;
|
||||
use Modules\Payment\Enums\PaymentStatus;
|
||||
use Modules\Shared\Enums\VehicleOption;
|
||||
|
||||
class BookingController extends Controller
|
||||
@@ -50,6 +51,17 @@ class BookingController extends Controller
|
||||
}
|
||||
|
||||
$bookings = $query
|
||||
// Only bookings that actually have a completed payment — a
|
||||
// pending_payment booking never had money move, so it's noise
|
||||
// in a booking list, not a real reservation to show.
|
||||
->whereHas('payments', fn ($paymentQuery) => $paymentQuery->where('status', PaymentStatus::Completed))
|
||||
// A round trip is two Booking rows (outbound + return leg,
|
||||
// linked via linked_booking_id — domain.md §2b), but it should
|
||||
// still surface once here, not as two separate list entries.
|
||||
// The outbound row's `linked_booking` already carries the
|
||||
// return leg's full detail (including vehicle_options).
|
||||
->where('is_return_leg', false)
|
||||
->when($request->filled('booking_ref'), fn ($q) => $q->where('booking_ref', 'ilike', '%'.$request->string('booking_ref').'%'))
|
||||
->with(self::EAGER_LOADS)
|
||||
->latest()
|
||||
->paginate();
|
||||
|
||||
Reference in New Issue
Block a user