I have a campaigns
table which is related shop
table based on shop_id
, There are also a rules
table which is related to campaigns
table based on for_camp_id
. I have to fetch the all the data from campaigns
table based on shop_id
with all the rules
created for that specific campaign. I used join query as
return DB::table('campaigns')
->join('rules', 'campaigns.for_camp_id', '=', 'rules.for_camp_id')
->where('campaigns.for_shop_id',$shopId)
->get();
But it gives me record as a array of collection having each collection with single rules
with campaign data. I want the result should be returned in proper formatting like a multidimensional array containing array for each campaign, and each campaign array containing created rules for it like
array(
'campaign1'=array(
'rule1'=>array(),
'rule2'=array()
),
'campaign2'=array(
'rule1'=>array(),
'rule2'=array()
),
)