Use a WHERE clause prior to the ORDER BY.
Jun 19, 2023
2
Level 1
how to use order by with condition in laravel?
Scenario: supposed i have data, where status is completed, now i want status completed displayed at the bottom, otherwise the most recent created displayed at the top, how can you query it using orderBY or any method in laravel? pls help im new in laravel thank you..
This is the query i tried: // The list of completed surveys is displayed at the bottom. Otherwise, the most recent date of creation is displayed at the top.
$surveys = $query->select('surveys.*')
->orderBy("status", 'asc')
->get();
Please or to participate in this conversation.