My current query is
select * from `users` where `group_id` = 1 and ((select count(*) from `works` inner join `user_work` on `works`.`id` = `user_work`.`work_id` where `user_work`.`user_id` = `users`.`id` and `work_duration_id` >= 3) >= 1)
For this query I have written following eloquent method in laravel 4.2 and it is working fine
$u = User::where('group_id', '=', 1);
$u = $u->where(function($m) use($minWorkDuration,$searchCriteria){
$m = $m->whereHas('work', function($q) use($minWorkDuration){
$q->where('work_duration_id', '>=', $minWorkDuration );
});
});
But I want to change in my query little bit and this is
select * from `users` where `group_id` = 1 and ((select count(*) from `works` inner join `user_work` on `works`.`id` = `user_work`.`work_id` where `user_work`.`user_id` = `users`.`id` and (SELECT SUM(`work_duration_id`) from `works` group by `user_id`) >= 3) >= 1)
If I want to write this query then what will be in eloquent method. If anybody is there please suggest me how to write this query in eloquent method in laravel 4.2. Thanks in advance.