Fetch a paginated list of Invitations for a selected Team

@return \Illuminate\Http\Response JSON object with pagination header member$members and data array with a list
of Invitation objects
322132
public function index()
    {
        $invitations = MemberInvitation::with(
            'member',
            'member.user',
            'inviter',
            'inviter.user'
        )
            ->active()
            ->forUserContext($this->userContext())
            ->orderBy('created_at', 'desc')
            ->paginate(config('app.pagination_default'));
        return fractal($invitations, new MemberInvitationTransformer())
            ->withResourceName('memberInvitation')
            ->respond();
    }
1182892
public function getTeam()
    {
        $response = $this->rest->get(
            static::TEAM_PATH
        );

        $this->checkResponse($response);

        return new Team($response);
    }
55494
public function listTeamMembers(int $id): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/teams/:id/members', (string)$id));
    }
514696
public function getList()
    {
        $response = $this->getResponse();
        $response->getHeaders()->addHeaderLine('Content-Type', 'application/json');
        $type = $this->params()->fromRoute("type", null);
        $anneeScolaire = $this->params()->fromRoute("annee_scolaire", null);
        if (! is_null($type)) {
            $formatter = $this->getServiceLocator()->get($type . AbstractFormatterFactory::$termination);
            $columns = $this->params()->fromQuery("columns", null);
            $start = $this->params()->fromQuery("start", null);
            $length = $this->params()->fromQuery("length", null);
            $order = $this->params()->fromQuery("order", null);
            $search = $this->params()->fromQuery("search", null);
            $data = $formatter->getData($columns, $start, $length, $order, $search, $anneeScolaire);
            $response->setContent(\Zend\Json\Json::encode($data));
        }
        
        return $response;
    }
1107659
public function getList()
    {
        /** @var RcmUserService $rcmUserService */
        $rcmUserService = $this->serviceLocator->get(RcmUserService::class);

        //ACCESS CHECK
        if (!$rcmUserService->isAllowed(
            ResourceName::RESOURCE_SITES,
            'admin'
        )
        ) {
            $this->getResponse()->setStatusCode(Response::STATUS_CODE_401);
            return $this->getResponse();
        }

        $config = $this->getConfig();

        $pageTypes = $config['Rcm']['pageTypes'];

        return new ApiJsonModel($pageTypes, 0, 'Success');
    }
595811
protected function _getOrganizationsList()
    {
        $html = new \MUtil_Html_Sequence();
        $sql = '
            SELECT *
            FROM gems__organizations
            WHERE gor_active=1 AND gor_url IS NOT NULL AND gor_task IS NOT NULL
            ORDER BY gor_name';

        // $organizations = array();
        // $organizations = array(key($organizations) => reset($organizations));
        $organizations = $this->db->fetchAll($sql);
        $orgCount = count($organizations);


        switch ($orgCount) {
            case 0:
                return $html->pInfo(sprintf($this->_('%s is still under development.'), $this->project->getName()));

            case 1:
                $organization = reset($organizations);

                $p = $html->pInfo(sprintf($this->_('%s is run by: '), $this->project->getName()));
                $p->a($organization['gor_url'], $organization['gor_name']);
                $p->append('.');

                $html->pInfo()->sprintf(
                        $this->_('Please contact the %s if you have any questions regarding %s.'),
                        $organization['gor_name'],
                        $this->project->getName()
                        );

                return $html;

            default:

                $p = $html->pInfo(sprintf(
                        $this->_('%s is a collaboration of these organizations:'),
                        $this->project->getName()
                        ));

                $data = \MUtil_Lazy::repeat($organizations);
                $ul = $p->ul($data, array('class' => 'indent'));
                $li = $ul->li();
                $li->a($data->gor_url->call($this, '_'), $data->gor_name, array('rel' => 'external'));
                $li->append(' (');
                $li->append($data->gor_task->call(array($this, '_')));
                $li->append(')');

                $html->pInfo()->sprintf(
                        $this->_('You can contact any of these organizations if you have questions regarding %s.'),
                        $this->project->getName()
                        );

                return $html;
        }
    }
547447
public function importsEventsIcsAction()
    {
        $form = $this->createForm(new ImportAgendaType());
        $form->handleRequest($this->request);

        if ($form->isValid()) {
            $events = $this->agendaManager->importEvents($form->get('file')->getData());

            return new JsonResponse($events, 200);
        }

        return ['form' => $form->createView()];
    }
855579
public function actionInvitePost()
	{
		$model = new InvitationForm;

		if (!empty($_POST))
		{
			$model->attributes = $_POST;

			// Save the user's information
			if ($model->invite())
				return Users::model()->findByAttributes(array('email' => $_POST['email']))->getAPIAttributes(array('password'), array('role', 'metadata'));
			else
				return $this->returnError(400, NULL, $model->getErrors());
		}

		throw new CHttpException(400, Yii::t('Api.user', 'An unexpected error occured fulfilling your request.'));
	}
872703
public function getList()
    {
        $list = \BearCMS\Internal\Data::getList('bearcms/users/invitation/');
        array_walk($list, function(&$value) {
            $value = $this->makeUserFromRawData($value);
        });
        return new \IvoPetkov\DataList($list);
    }
1371396
public function index()
    {
        $jobs = Job::onTeam()
            ->where('start', '>', Carbon::now()->yesterday())
            ->with(
                'members',
                'member_tags',
                'location'
            )
            ->orderBy('start', 'asc')
            ->paginate(config('app.pagination_default'));
        return fractal($jobs, new JobTransformer())
            ->withResourceName('job')
            ->respond();
    }
596420
public function index(TeamRequest $request)
    {
        $view = $this->response->theme->listView();

        if ($this->response->typeIs('json')) {
            $function = camel_case('get-' . $view);
            return $this->repository
                ->setPresenter(\Litecms\Team\Repositories\Presenter\TeamPresenter::class)
                ->$function();
        }

        $teams = $this->repository->paginate();

        return $this->response->title(trans('team::team.names'))
            ->view('team::team.index', true)
            ->data(compact('teams'))
            ->output();
    }
664284
public function getMembers()
    {
        if (empty($this->aMembers)) {
            $this->aMembers = [];
            if ($this->id) {
                foreach (Sked::getEventMembers($this->id) as $aEventMember)
                    $this->aMembers[$aEventMember['member_id']] = $aEventMember;
            }
        }
        return $this->aMembers;
    }
368468
protected function createInvitedMember(Request $request)
    {
        $invitedUser = $this->getInvitedUser($request);
        $invitedMember = new Member();
        $invitedMember->team_id = $this->userContext()->team_id;
        $invitedMember->user_id = $invitedUser->id;
        $invitedMember->save();
        return $invitedMember;
    }
533085
public function getMembers()
    {
        if (!array_key_exists(self::MEMBERS, $this->group)) {
            throw new \Exception('Could not get group members from group id.');
        }
        return $this->group[self::MEMBERS];
    }
329371
public function showTeamView()
    {
        $team = User::all();

        return View::make('dashboard.team.index')
            ->withPageTitle(trans('dashboard.team.team').' - '.trans('dashboard.dashboard'))
            ->withTeamMembers($team);
    }
1260244
protected function getPaginatedMembers()
    {
        $members = [];

        $keys = array_keys($this->attributes);

        // We need to filter out the model attributes so
        // we only retrieve the member range.
        $attributes = array_values(array_filter($keys, function ($key) {
            return strpos($key,'member;range') !== false;
        }));

        // We'll grab the member range key so we can run a
        // regex on it to determine the range.
        $key = reset($attributes);

        preg_match_all(
            '/member;range\=([0-9]{1,4})-([0-9*]{1,4})/',
            $key,
            $matches
        );

        if ($key && count($matches) == 3) {
            // Retrieve the ending range number.
            $to = $matches[2][0];

            // Retrieve the current groups members from the
            // current range string (ex. 'member;0-50').
            $members = $this->getMembersFromAttribute($key);

            // If the query already included all member results (indicated
            // by the '*'), then we can return here. Otherwise we need
            // to continue on and retrieve the rest.
            if($to === '*') {
                return $members;
            }

            // Determine the amount of members we're requesting per query.
            $range = $to - $matches[1][0];

            // Set our starting range to our last end range plus one.
            $from = $to + 1;

            // We'll determine the new end range by adding the
            // total range to our new starting range.
            $to = $from + $range;

            // We'll need to query for the current model again but with
            // a new range to retrieve the other members.
            /** @var Group $group */
            $group = $this->query->newInstance()->findByDn(
                $this->getDn(),
                [$this->query->getSchema()->memberRange($from, $to)]
            );

            // Finally, we'll merge our current members
            // with the newly returned members.
            $members = array_merge(
                $members,
                $group->getMembers()->toArray()
            );
        }

        return $members;
    }
559195
public function get_selected_users() {
        // Do a lazy load.
        if (is_null($this->selected)) {
            $this->selected = $this->load_selected_users();
        }
        return $this->selected;
    }