I have a MySQL query like this:
SELECT
a.id,
a.nip,
a.name,
COUNT(
(
SELECT id
FROM covis_transactions
WHERE user_id = a.id
)
) AS total_survey
FROM users a
WHERE a.user_role_id = 7
GROUP BY a.id
I tried converting it to an Eloquent query but this seems not to work:
DB::table('users as a')
->selectRaw("a.id, a.nip, a.name, COUNT(".DB::table('covis_transactions')->where('user_id', 'a.id').") as total_survey")
->where('a.user_role_id', 7)
->groupBy('a.id')
->get();