public function filter($route, $request, $group) { $group = is_int($group) ? $this->groups->findById($group) : $this->groups->findByName($group); if ($group && (!$this->auth->check() || !$this->auth->getUser()->inGroup($group))) { return App::abort(401, 'You are not authorized.'); } }
/** * Remove user from a group. * * @param int $userId * @param int $groupId * @return \Illuminate\Http\RedirectResponse */ public function destroy($userId, $groupId) { $user = $this->users->findById($userId); $group = $this->groups->findById($groupId); $this->users->removeGroup($user, $group); return Redirect::route('users.groups.index', $userId); }
public function testDelete() { $mock = m::mock('Group'); $mock->shouldReceive('delete')->once()->andReturn(true); Sentry::shouldReceive('findGroupById')->with(1)->once()->andReturn($mock); $this->assertTrue($this->groups->delete(1)); Sentry::shouldReceive('findGroupById')->once()->andThrow('Cartalyst\\Sentry\\Groups\\GroupNotFoundException'); $this->assertFalse($this->groups->delete(10)); }
/** * Remove the specified group from storage. * * @param int $id */ public function destroy($id) { $this->groups->delete($id); return Redirect::route('groups.index'); }