I want to get menus from database which may also have sub menus. For all menus passed to views I want to check if they have sub menus or not and perform the action accordingly. If it was on codeigniter I could do like following:
Controller:
function test()
{
$qry=$this->db->get('menus');
if($qry)
{
$this->data['menu_data']=$qry->result();
}
$this->laod->view('abc',$this->data);
}
View abc
<?php foreach($menu_data as $val) {?>
<li><a href=""><?php echo $val->title; ?>
<? php $submenu=$this->general->get_submenu($val->id); foreach($submenu as $smvalue {) ?>
<ul>
<li><?php echo $smvalue->title?></li>
</ul>
<?php } ?>
<li>
<?php } ?>
Say the general is a Library class and there get_submenus function lies. In Laravel how do I do it? I am very new to Laravel and just starting to practice.Any kind of help are appreciated. Thanks in advance.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2mrdc5v
via IFTTT
Aucun commentaire:
Enregistrer un commentaire