Exemple #1
0
 /**
  * Loads the necessary data for the class
  */
 protected function prepare()
 {
     if (app('session')->has('menu_list')) {
         $this->menuList = app('session')->pull('menu_list');
     } elseif (\Auth::user()) {
         $userId = \Auth::user()->id;
         $userModel = ModelFactory::getInstance('User');
         $user = $userModel->with('group.navigations.navitems')->find($userId);
         $this->menuList = $user->group->navigations->toArray();
         // store this to session so that we'll just pull the data from session
         // and no longer need to Query again
         app('session')->put('menu_list', $this->menuList);
     }
     $this->prepared = true;
 }
Exemple #2
0
 public function isActionAllowed($action)
 {
     $user = \Auth::user();
     if (!$user) {
         return true;
     }
     $groupId = $user->group->id;
     if (isset($this->menuItemExclude[$groupId][$action])) {
         return false;
     }
     return true;
 }