src/Controllers/ResourceController.php
public function getIndex(Request $request, $resource, $id = null, $args = null) {
		// Resource.
		$resource = $this->mapper->map($resource);

		if ($relations = $request->input('with')) {
			$relations = explode(",", $relations);
		}

		if ($id) {
			$result = $this->loader->loadEntity($resource, $id, $relations);

			// @TODO return child relation as resource.
			// We'll need the parent entity ID in order
			// to trigger repository access for child, i.e.
			// get:/resources/users/1/profile we need to
			// know which key bind profile to users.

			if ($args) {
				$args = explode("/", $args);
				return $result->{$args[0]};
			} else {
				return $result;
			}
		}

		else {
			$page = $request->get('page', 1);
			$ipp = $request->get('ipp', 50);

            // Apply criteria.
            $this->loader->query(RemoteQuery::spawn($request->input('qparams')));

            // Load.
            return $this->loader->loadEntities($resource, $page - 1, $ipp, $relations);
		}
	}
public function getIndex(Request $request, $resource, $id = null, $args = null) {
		// Resource.
		$resource = $this->mapper->map($resource);

		if ($relations = $request->input('with')) {
			$relations = explode(",", $relations);
		}

		if ($id) {
			$result = $this->loader->loadEntity($resource, $id, $relations);

			// @TODO return child relation as resource.
			// We'll need the parent entity ID in order
			// to trigger repository access for child, i.e.
			// get:/resources/users/1/profile we need to
			// know which key bind profile to users.

			if ($args) {
				$args = explode("/", $args);
				return $result->{$args[0]};
			} else {
				return $result;
			}
		}

		else {
			$page = $request->get('page', 1);
			$ipp = $request->get('ipp', 50);

            // Apply criteria.
            $this->loader->query(RemoteQuery::spawn($request->input('qparams')));

            // Load.
            return $this->loader->loadEntities($resource, $page - 1, $ipp, $relations);
		}
	}
/api/v1/resources/[resource]/{id?}/{relation?}?with=rel1,rel2&qparams={}

@param Request $request
@param string  $resource
@param int     $id
@param string  $args

@return mixed