Example #1
0
 public function __construct()
 {
     if (Auth::check()) {
         $groups = Auth::user()->groups();
         $menu = [];
         if (in_array('Administrator', $groups)) {
             $menu[] = ['text' => 'Sales', 'url' => '/sales'];
             $menu[] = ['text' => 'Create Sale', 'url' => '/sales/create'];
             $menu[] = ['text' => 'Admin', 'url' => '/admin'];
         } else {
             if (in_array('Agent', $groups)) {
                 $menu[] = ['text' => 'Create Sale', 'url' => '/sales/create'];
             } else {
                 if (in_array('QC', $groups)) {
                     $menu[] = ['text' => 'Sales', 'url' => '/sales'];
                 }
             }
         }
         $userRepo = new UserRepo();
         $e = $userRepo->findEmployee(Auth::user()->id);
         if ($e) {
             $this->employeeId = $e->id;
         }
         View::share('myData', $e);
         View::share('menu', $menu);
         $id = Input::get('id');
         if ($id) {
             $this->userId = $id;
         } else {
             $this->userId = Auth::user()->id;
         }
     }
 }
Example #2
0
 public function groups()
 {
     $repo = new UserRepo();
     return $repo->findGroups($this->id);
 }