The answer that user1977808 gave you is not very good, because MySQL cannot use the index in the timestamp column, since it must calculate the output of the DATE_SUB function for each row. Avoid such queries; they must process the entire table every time!
How about something like this:
return MainContact::where('timestamp', '>=', time() - (24*60*60))->get();
I put >= there because you said "day or less old", so they should have a timestamp that was later than yesterday.
duality_
source share