0
have that method :
public function Menu()
{
$tabelas = $this->menu->All();
$menus ="<ul><li>";
foreach ($tabelas as $tabela )
{
if ($tabela->active == !false)
{
// $return = $this->categoria->All();
foreach ($tabela as $key => $value )
{
if($key->active == !false)
{
$menus .="<li>{$key} <a href= ></a></li> ";
}
}
}
$menus.= "</li></ul>";
}
return $menus ;
}
wanted to know how to call him in the view , to see how he’s returning and putting things together ...
public function create()
{
$this->setPageTitle('Menu');
echo $this->categoria->Menu(); die;
$this->renderView('rotas/RouteMenus', 'layoutForm');
}
ta giving error :Uncaught Error: Call to a Member Function Menu() on null
you shouldn’t do that. What’s the problem that happens?
– rray
I want to set up my menu dynamically giving a select in the table of the bank , I already tested my select which is that call for the method all() there is bringing good , and now I just wanted to give a call in this menu method in the view to see how it is mounting the <ul> and tals
– Pedro Amorim
Save the return of
Menu()
in a variable give an echo for testing or pass it straight to view, then give an echo.– rray
I played an echo inside the method that renders to view more error :Uncaught Error: Call to a Member Function Menu() on null
– Pedro Amorim
By the code of to suppose some things. By calling
$this->categoria->Menu()
, in that order it would be necessary that the propertycategoria
returns an instance of the class where the function was createdMenu()
. By the description of the error presented to realize that$this->categoria
returns the valuenull
. It would be interesting to indicate in which classes are the functions shown.– Juven_v