I’m building a booking system in Laravel, look at below image
Today is 3, my customers booked in current month 1,6,8,10,12 and 25. I want to send a notification to those who left 6 days from today.
I want to send a notification to customers booked on 6 and 8 only and tomorrow I’ll send notification to 10 as well.
I tried
public function test(){
$orders = Order::whereDate('booked_at','>=',Carbon::now()->addDays(6))->get();
return $orders;
}
the above code return all the future booking not only 6 days from today.
any suggestion appreciated.
3
Answers
you can try something like this
I suggest this, to easy changes the daysLeft on the next time you want to changes.
You are using
>=
to comparebooked_at
which will give you all orders that are booked at 6 days or more from now.If you want all orders booked exactly 6 days from now you can use: