SELECT requests.*, comments.text
FROM (SELECT export_id, max(imported_at) AS imported_at
FROM requests
GROUP BY export_id) as t
JOIN requests ON requests.export_id = t.export_id
AND requests.imported_at = t.imported_at
LEFT JOIN comments ON comments.spreadsheet_export_id = t.export_id
ORDER BY `requests`.export_id DESC
DB::enableQueryLog();
$categories = Category::with(['products' => function ($q) {
$q->where('active', 1)->orderBy($this->sortField, $this->sortAsc ? 'asc' : 'desc');
}])->orderBy('sorting')->get();
dd(DB::getQueryLog());
select * from categories order by sorting;
select * from products where category_id in (здесь список id полученных в первом запросе) and active = 1 order by sortField asc;
public function toArray($request)
{
$array = [
'name' => $this->name,
'email' => $this->email,
];
if ($this->resource->hasVerifiedEmail()) {
$array['balance'] = 100;
}
return $array;
}