App For Rental Car :
I need check car if available between 2 date and check quantity ("column name : qty"),
There is no need for a car more than the available number of cars (number cars booking < QTY car )
When change number 3 in the name of the column (‘qty’) does not work.
Query From Url : $PickupStartDate,$DropEndDate;
Car::withCount('reservation')->having('reservation_count', '<', 3)->get();
Tables :
Cars
ID | name | price | qty|
Reservations
ID | start_date | end_date | days | start_place | return_place | car_id |
check if car available for rental check we have a car between date
2
Answers
Solution :
in code Check Car.qty< car.reservation_count
Try this