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();
from Laravel Questions and Answers https://laravelquestions.com/laravel/how-can-i-send-one-query-result-via-variable-into-an-other-query/
via Lzo Media
No comments:
Post a Comment