Answer the question
In order to leave comments, you need to log in
What is the best way to overwrite subquery on builder in laravel?
$query = Name::query()
->selectRaw('count(*) as subs,
(SELECT count(*) FROM customers where active = 0 order by updated_at) as unsubs, sum(device = 1) as pc,
sum(device = 0) mob');
Answer the question
In order to leave comments, you need to log in
Use withCount with a closure - https://laravel.com/docs/5.7/eloquent-relationship...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question