How to ORDER BY in Where Condition in Editor?

How to ORDER BY in Where Condition in Editor?

oopsleonoopsleon Posts: 9Questions: 4Answers: 0

Hi team,

I would like the table to only query the latest 600 records order by a date desc if it meet a certain condition.

My codes in Editor are as bleow:

->where(function ($q) use ($filter) {
    global $filterJs;
    if ($filterJs == 8) {
        $q->where('jobs.status', '(8)', 'IN', false);
        $q->limit(600);
        $q->order('invoiced_date', 'DESC')
    } else {
        $q->where('jobs.status', $filter, 'IN', false);
    }
})

But the DESC does not work.
Whether I use ASC or DESC, I always got the oldest 600 records.
Could you please help?

Thank you very much!

Answers

  • oopsleonoopsleon Posts: 9Questions: 4Answers: 0

    Shit~I just realised I put limit() before order(). LOL!

Sign In or Register to comment.