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(); }
public static function usersof($role) { return Role::where("title", "student")->get()->first()->users; }