'Eloquent Query builder using orderby count having with clause
select `tableA`.*, (select count(*) from `tableB` where `tableA`.`id` =
`tableB`.`sid` and `tableB`.`status` = 'true' ) as `count`, (select name from
`tableC` where `tableA`.`id` = `tableC`.`sid` and (`CCol` = 'en' or `CCol` = 'id')
order By field(`CCol`, 'id','en') limit 1) as CCol from `tableA` where
`status` = 'true' order by `count` desc, `CCol` asc limit 10
Could you help me out to change this query in eloquent ORM builder. I have tried but couldnt found out how to add where clause in count
$A = $A->withCount('B')
->orderBy('count', 'desc');
$A->orderBy('CCol', 'ASC');
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
