Esempio n. 1
0
 /**
  * Register any application authentication / authorization services.
  *
  * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
  * @return void
  */
 public function boot(GateContract $gate)
 {
     $this->registerPolicies($gate);
     $gate->before(function ($user, $ability) {
         if ($user->isSuperAdmin()) {
             return true;
         }
     });
     $gate->define('redactor', function ($user) {
         $level = AuthLevel::where('title', 'redactor')->first()->level;
         if ($user->AuthLevel != null) {
             return $user->AuthLevel->level >= $level;
         }
         return false;
     });
     $gate->define('moderator', function ($user) {
         $level = AuthLevel::where('title', 'moderator')->first()->level;
         if ($user->AuthLevel != null) {
             return $user->AuthLevel->level >= $level;
         }
         return false;
     });
     $gate->define('administrator', function ($user) {
         $level = AuthLevel::where('title', 'administrator')->first()->level;
         if ($user->AuthLevel != null) {
             return $user->AuthLevel->level >= $level;
         }
         return false;
     });
 }
Esempio n. 2
0
 public function EditUser($id)
 {
     $user = User::find($id);
     if ($user == null) {
         abort(404);
     }
     $authLevels = AuthLevel::select('id', 'label')->get();
     foreach ($authLevels as $al) {
         $auths[$al->id] = $al->label;
     }
     return view('admin.users.edit', array('user' => $user, 'authLevels' => $auths));
 }