I have created a database driven menu using a Controller,
HomeController extends Controller which the menu is loaded in Controller's construct function.
HomeController.php
class HomeController extends Controller
{
public function __construct()
{
parent::__construct();
$this->middleware('auth');
}
public function index(){
$data['menu'] = $this->menu;
return view('home', $data);
}
}
Controller.php
public function __construct()
{
$this->user = Auth::user();
$menu = new Menu();
if($this->user != NULL && $this->user != ""){
$this->menu = $menu->getMenu($this->user->user_id);
}
}
How can I, call the function straight at the view level because right now, even though the menu is loaded in the constructor, I will still need to pass the menu to the view which makes things a bit redundant.
P/S: Using laravel 5.1
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire