Query Builder, where compare date shifted by N days

Viewed 28

In my laravel app I have a table with 2 relevant fields:

  • updated_at timestamp of last review
  • n number of days until next review.

I am trying to write a query that returns records which are due for review. In PHP, I would do something like this:

updated_at->addDays(n) > Carbon::now()

Looking at the query builder docs, I am thinking something like the subquery where clause would be helpful, but am unsure how to approach it. Particularly as I need to use a field from the table in both sides of the where.

->where('updated_at', '>', function ($query) {
    //
})
0 Answers
Related