0

I want to get queries order by the end date also if the status is == completed, I want to show it last if the date is order by or not. The below code gives me a result as order by the end date. it's work but if the status is equal how does it sort into the last in the list? my status column has "Processing", "Completed"

$this->paperorders = paperorder::with('order', 'client', 'paperorders', 'papers', 'stocks')->orderBy('end_at', 'asc')->get();

DB Table screenshot

  • $this->paperorders = paperorder::with('order', 'client', 'paperorders', 'papers', 'stocks')->orderBy('end_at', 'asc')->orderBy('status', 'desc')->get(); – R.tbr Oct 04 '21 at 09:17
  • you can use orderByRaw like ->orderByRaw("FIELD(status , 'completed', 'pending', 'delayed', 'closed') ASC") – Kaushal Patel Oct 04 '21 at 09:30
  • ->orderByRaw("FIELD(status , 'completed', 'pending', 'delayed', 'closed') ASC") this is work for me. Thanks a lot. – Madushan Serasinghe Oct 05 '21 at 04:40

0 Answers0