Do you mean sql unions? https://laravel.com/docs/5.6/queries#unions
Apr 26, 2018
4
Level 1
How can i send one query result (via variable) into an other query
What I want is to include the result of sub variable into another query.
$sub = DB::table('chef_food_ethics')->
select(DB::raw('count(id) as fCount'))
->where('chef_food_ethics.food_ethic_id',
'=','food_ethic_managers.food_ethic_id')
->toSql();
Is it possible to include it like that?
$r = DB::table('food_ethic_managers')where
('food_ethic_managers.manager_id','=',$id)
->leftJoin('staff','food_ethic_managers.food_ethic_id'
,'=','staff.id')
->leftJoin('regions','staff.region_id','=','regions.id')
->with($sub)
->get();
Please or to participate in this conversation.