I have a field in my database called "deadline" which is of DATE format, and I want to use Eloquent to say that if the deadline field does not match Carbon::now();
but isn't in the future then don't show this row.
How can I achieve this?
I have a field in my database called "deadline" which is of DATE format, and I want to use Eloquent to say that if the deadline field does not match Carbon::now();
but isn't in the future then don't show this row.
How can I achieve this?
Select records where deadline
is greater than or equal to today's date()
in the Y-m-d
format.
Model::where('deadline','>=', date('Y-m-d'))->get();
Laravel works with Carbon for formatting timestamps etc, which you can easily set the deadline
column as one of those Carbon objects with a Laravel date mutator allowing you formatting abilities.
But for a select statement, i'd just use the above personally.