src/Controller/GETById.php
protected static function handleGETById(
        $parameters,
        $id,
        $modelClass,
        $primaryDataParameters = [],
        $relationshipParameters = []
    ) {
        $filterValidationModel = $modelClass::getFilterValidationModel();

        $idAttribute = $modelClass::getIdAttribute();

        //Filter id attribute value
        if (!empty($filterValidationModel) && isset($filterValidationModel->{$idAttribute})) {
            $id = $filterValidationModel->{$idAttribute}->parse($id);
        }

        $fields = $modelClass::parseFields($parameters);

        $requestInclude = static::getRequestInclude($parameters, $modelClass);

        $data = $modelClass::getById(
            $id,
            $fields,
            ...$primaryDataParameters
        );

        //Check if resource exists
        static::exists($data);

        $includedData = $modelClass::getIncludedData(
            $data,
            $requestInclude,
            $fields,
            $relationshipParameters
        );

        return static::viewData(
            $data,
            (object) [
                'self' => $modelClass::getSelfLink($id)
            ],
            null,
            (empty($requestInclude) ? null : $includedData)
        );
    }
protected static function handleGETById(
        $parameters,
        $id,
        $modelClass,
        $primaryDataParameters = [],
        $relationshipParameters = []
    ) {
        $filterValidationModel = $modelClass::getFilterValidationModel();

        $idAttribute = $modelClass::getIdAttribute();

        //Filter id attribute value
        if (!empty($filterValidationModel) && isset($filterValidationModel->{$idAttribute})) {
            $id = $filterValidationModel->{$idAttribute}->parse($id);
        }

        $fields = $modelClass::parseFields($parameters);

        $requestInclude = static::getRequestInclude($parameters, $modelClass);

        $data = $modelClass::getById(
            $id,
            $fields,
            ...$primaryDataParameters
        );

        //Check if resource exists
        static::exists($data);

        $includedData = $modelClass::getIncludedData(
            $data,
            $requestInclude,
            $fields,
            $relationshipParameters
        );

        return static::viewData(
            $data,
            (object) [
                'self' => $modelClass::getSelfLink($id)
            ],
            null,
            (empty($requestInclude) ? null : $includedData)
        );
    }
protected static function handleGETById ( $ parameters , $ id , $ modelClass , $ primaryDataParameters = [ ] , $ relationshipParameters = [ ] ) { $ filterValidationModel = $ modelClass :: getFilterValidationModel ( ) ; $ idAttribute = $ modelClass :: getIdAttribute ( ) ; //Filter id attribute value if ( ! empty ( $ filterValidationModel ) && isset ( $ filterValidationModel -> { $ idAttribute } ) ) { $ id = $ filterValidationModel -> { $ idAttribute } -> parse ( $ id ) ; } $ fields = $ modelClass :: parseFields ( $ parameters ) ; $ requestInclude = static :: getRequestInclude ( $ parameters , $ modelClass ) ; $ data = $ modelClass :: getById ( $ id , $ fields , ... $ primaryDataParameters ) ; //Check if resource exists static :: exists ( $ data ) ; $ includedData = $ modelClass :: getIncludedData ( $ data , $ requestInclude , $ fields , $ relationshipParameters ) ; return static :: viewData ( $ data , ( object ) [ 'self' => $ modelClass :: getSelfLink ( $ id ) ] , null , ( empty ( $ requestInclude ) ? null : $ includedData ) ) ; }
handles GETById requests
@param  object $parameters                          Request parameters
@param  integer|string $id                      Requested resource's id
@param  string $modelClass                      Resource's primary model
to be used
@param  array $primaryDataParameters           [Optional] Array with any
additional arguments that the primary data is requiring
@param  array $relationshipParameters [Optional] Array with any
additional argument primary data's relationships are requiring
@uses model's `getById` method to fetch resource
@return boolean
@todo Force parsing of relationship data when included
handles GETById requests