So I'm writing a Laravel 4 app and I've setup namespaces. I'm just trying to write some systemwide functionality that I can execute from anywhere mainly to create menus/setup language/currencies etc.
I have directory to global called "library" which has currently a file called Menu.php inside it which looks as follows:
<?php
namespace Library;
use AppName\Model\Menu as MenuModel;
class Menu {
public static function BuildMenu($id = 1) {
//retrieve menu
$menu = MenuModel::GetMenu($id);
//sort content for page
$data = $menu->toArray();
print_r($data);
}
}
I am currently attempting to call the BuildMenu function in the filters.php file with the following:
App::before(function($request)
{
//
View::share('Menu', Library\Menu::BuildMenu());
});
I get a class 'Library\Menu' not found error from laravel. I'm presuming this is something to do with my lack of knowledge of namespaces so any clarity would be appreciated.