I need to set up a menu using the registered categories. How can I do this without using a view
?
I have my layout.blade.php
with a @include('sidebar')
My query works on view
categorias.blade.php
, I just need to receive query data on my sidebar.blade.php
CategoryController:
public function listar() {
$categorias = Categoria::where('categoria_id', '0')->with('todasCategorias')->get();
return view('categorias', compact('categorias'));
}
I made the direct query in sidebar.blade.php
.
It worked, but I think this is not the right way, does anyone know otherwise?
$categorias = App\Categoria::where('categoria_id', '0')->with('todasCategorias')->get()