Post here your database structure and what do you want as a result. The way you are doing it here is wrong. If you can start your query from orders table.
Mar 9, 2021
5
Level 2
How to list order by id
Hi,
I have a panel and a report crud in it. On the index page, I want to list the data sorted by id. I added in my query but nothing changed. If you have an idea please let me know
$userId = $user->id;
$firms = Customer::whereHas('related_people', function ($q) use ($userId) {
$q->where('id', $userId);
})->get();
foreach ($firms as $firm){
$analysisReports = AnalysisReport::where('costumer_id',$firm->id)->where('approved_by_id','!=','')->orderBy('id','DESC')->get();
}
Thanks in advance
Level 61
Please or to participate in this conversation.