/** * Run the database seeds. * * @return void */ public function run() { $roles = R::$roles; foreach ($roles as $role) { $r = Role::create($role); } }
/** * Run the database seeds. * * @return void */ public function run() { $rolesWithPermissions = R::rolesWithPermissions(); foreach ($rolesWithPermissions as $roleName => $permissions) { $role = Role::whereName($roleName)->first(); foreach ($permissions as $permissionName) { $permission = Permission::whereName($permissionName)->first(); $role->assignPermission($permission); } } }
/** * Run the database seeds. * * @return void */ public function run() { User::whereUsername('admin')->first()->assignRole(Role::whereName('admin')->first()); User::whereUsername('user')->first()->assignRole(Role::whereName('user')->first()); }
/** * return all available role for this user * * @param User $user * @return array */ public function getRolesFor(User $user) { $userRoles = $user->roles()->get(); $roles = Role::where('order', '<=', $this->maxRole()->order); foreach ($userRoles as $role) { $roles = $roles->where('name', '!=', $role->name); } return $roles->get(); }