Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

theUnforgiven's avatar

Showing records based on date

I have a field in my database called "deadline" which is has DATE 2015-01-01 format.

I want to use Eloquent to say that if the deadline field does not match today's date and is in the past then don't show the record, otherwise if it's a future date then show the record.

How can I achieve this?

0 likes
2 replies
theUnforgiven's avatar
theUnforgiven
OP
Best Answer
Level 51

Figured it out by doing:

Model::where('deadline','>=', date('Y-m-d'))->get();
1 like
JarekTkaczyk's avatar
Model::where('deadline', '>=', DB::raw('curdate()'))->get();
// or
Model::where('deadline', '>=', Carbon::today())->get();
1 like

Please or to participate in this conversation.