Я хочу написать этот запрос, используя eloquent в Laravel.
select *
from tbl_lawyers as l
where ( select count(*)
from cooprations as c
where c.fk_lawyer_id = l.lawyer_id
and c.fk_coopration_id in ($request->cooprations))>= count($request->cooprations);
Как мне это написать?
Я написал это с >=
, но это не работает.
$query->join('tbl_lawyer_cooperation', function ($s) use ($request) {
$s->on('tbl_lawyer_cooperation.fk_lawyer_id', '=', 'vw_lawyers.lawyer_id')
->where(function ($d) use ($request) {
$d->select('count')
->whereIn('tbl_lawyer_cooperation.fk_cooperation_id', $request->cooprations);
},'>=',count($request->cooprations));
});