In my Controller, I have:
$level1Navs = tblPages::where('pgeParent','=',0)->orderBy('pgeOrder','ASC')->orderBy('pgeTitle','ASC')->get();
var_dump($level1Navs);
foreach($level1Navs as $level1Nav) {
$navbar = array();
$navbar['pgeID'] = $level1Nav->pgeID;
$navbar['pgeTitle'] = $level1Nav->pgeTitle;
$navbar['pgeContent'] = $level1Nav->pgeContent;
$navbar['pgeMainLevel'] = $level1Nav->pgeMainLevel;
$navbar['level2'] = array();
$level2Navs = tblPages::where('pgeParent','=',$level1Nav->pgeID)->where('pgeActive','=',1)->orderBy('pgeOrder','ASC')->orderBy('pgeTitle','ASC')->get();
foreach($level2Navs as $level2Nav) {
$navbar['level2']['pgeID'] = $level2Nav->pgeID;
$navbar['level2']['pgeTitle'] = $level2Nav->pgeTitle;
$navbar['level2']['pgeContent'] = $level2Nav->pgeContent;
$navbar['level2']['pgeMainLevel'] = $level2Nav->pgeMainLevel;
$navbar['level2']['level3'] = array();
$level3Navs = tblPages::where('pgeParent', '=', $level2Nav->pgeID)->where('pgeActive', '=', 1)->orderBy('pgeOrder', 'ASC')->get();
foreach ($level3Navs as $level3Nav) {
$navbar['level2']['level3']['pgeID'] = $level3Nav->pgeID;
$navbar['level2']['level3']['pgeTitle'] = $level3Nav->pgeTitle;
$navbar['level2']['level3']['pgeContent'] = $level3Nav->pgeContent;
$navbar['level2']['level3']['pgeMainLevel'] = $level3Nav->pgeMainLevel;
}
}
}
var_dump($navbar);
There are 9 items off the first level, but when it hits the var_dump, I only get this:
array (size=5)
'pgeID' => string '10' (length=2)
'pgeTitle' => string 'News' (length=4)
'pgeContent' => string '0' (length=1)
'pgeMainLevel' => string '10' (length=2)
'level2' =>
array (size=5)
'pgeID' => string '50' (length=2)
'pgeTitle' => string 'News Stories' (length=12)
'pgeContent' => string '1' (length=1)
'pgeMainLevel' => string '10' (length=2)
'level3' =>
array (size=0)
empty
Its like its only running through each foreach one time.
Am I missing something simple?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1MM2jiV
via IFTTT
Aucun commentaire:
Enregistrer un commentaire