Level 1
@tisuchi help me here plz.
4 likes
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi,
Is there the proper way to check the database date if smaller than "before date" then do the restriction?
currently What I have is
if (count(Sale::where('date','<=' ,'2018-08-01')->get()) > 0 ) {
echo "Sales is closed";
return false;
}else {
echo "Sales is open";
return true;
}
The sale will closed for the date that before 2018-08-01 and new sale will open after the date.
You can use count() method directly after the query.
For example-
if (Sale::where('date','<=' ,'2018-08-01')->count() > 0 ) {
//restriction
}else {
//not restrication
}
Please or to participate in this conversation.