Exemple #1
0
 public function storePerm()
 {
     $input = Request::except('_token');
     if (count($input) > 0) {
         foreach ($input as $key => $val) {
             $role = Role::where('name', '=', $key)->first();
             $role->perms()->sync([]);
             foreach ($val as $name) {
                 $checkperm = Permission::where('name', '=', $name)->first();
                 if (count($checkperm) > 0) {
                     $role->attachPermission($checkperm);
                 } else {
                     $perm = new Permission();
                     $perm->name = $name;
                     $perm->save();
                     $role->attachPermission($perm);
                 }
             }
         }
     }
     return redirect()->back();
 }
Exemple #2
0
 public static function usersof($role)
 {
     return Role::where("title", "student")->get()->first()->users;
 }