Код: Выделить всё
$first_wash = Washticket::
with([
'place_used',
'user' => function($q){
$q->withCount([
'washtickets as tickets_usados' => function($q){
$q->has('place_used')->where('paid', 1);
}
]);
},
])
->havingRaw('user.tickets_usados = 1') orderBy('used_at', 'desc')
->limit(100)
->get()
;
Код: Выделить всё
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'user.tickets_usados' in 'having clause' (SQL: select * from `washtickets` where `washtickets`.`deleted_at` is null having user.tickets_usados = 1 order by `used_at` desc limit 100)
Спасибо!
Подробнее здесь: https://stackoverflow.com/questions/784 ... tion-field