public function item(ResourceManager $resourceManager, ApiRequest $request, int $version, string $resource, $id)
    {
        $resourceManager->version($version);

        /** @var \Ipunkt\LaravelJsonApi\Contracts\RequestHandlers\HandlesItemRequest $handler */
        $handler = $this->initializeHandler($resourceManager, $resource, $request, HandlesItemRequest::class);

        $parameters = $request->asParameters();

        $repository = $this->initializeRepository($resourceManager, $resource, $parameters);

        $result = $handler->handle($id, $repository, $parameters);

        if ($result instanceof \Illuminate\Support\Collection) {
            $document = $this->makeDocumentFromCollection($resourceManager, $resource, $result, $parameters, $handler);
        } else {
            $document = $this->makeDocumentFromResource($resourceManager, $resource, $result, $parameters, $handler);
        }

        return $this->respond($document);
    }
public function item(ResourceManager $resourceManager, ApiRequest $request, int $version, string $resource, $id)
    {
        $resourceManager->version($version);

        /** @var \Ipunkt\LaravelJsonApi\Contracts\RequestHandlers\HandlesItemRequest $handler */
        $handler = $this->initializeHandler($resourceManager, $resource, $request, HandlesItemRequest::class);

        $parameters = $request->asParameters();

        $repository = $this->initializeRepository($resourceManager, $resource, $parameters);

        $result = $handler->handle($id, $repository, $parameters);

        if ($result instanceof \Illuminate\Support\Collection) {
            $document = $this->makeDocumentFromCollection($resourceManager, $resource, $result, $parameters, $handler);
        } else {
            $document = $this->makeDocumentFromResource($resourceManager, $resource, $result, $parameters, $handler);
        }

        return $this->respond($document);
    }
public function item ( ResourceManager $ resourceManager , ApiRequest $ request , int $ version , string $ resource , $ id ) { $ resourceManager -> version ( $ version ) ; /** @var \Ipunkt\LaravelJsonApi\Contracts\RequestHandlers\HandlesItemRequest $handler */ $ handler = $ this -> initializeHandler ( $ resourceManager , $ resource , $ request , HandlesItemRequest :: class ) ; $ parameters = $ request -> asParameters ( ) ; $ repository = $ this -> initializeRepository ( $ resourceManager , $ resource , $ parameters ) ; $ result = $ handler -> handle ( $ id , $ repository , $ parameters ) ; if ( $ result instanceof \ Illuminate \ Support \ Collection ) { $ document = $ this -> makeDocumentFromCollection ( $ resourceManager , $ resource , $ result , $ parameters , $ handler ) ; } else { $ document = $ this -> makeDocumentFromResource ( $ resourceManager , $ resource , $ result , $ parameters , $ handler ) ; } return $ this -> respond ( $ document ) ; }
handles an item request to a resource

/public/v1/resource/id
/secure/v1/resource/id

@param ResourceManager $resourceManager
@param \Ipunkt\LaravelJsonApi\Http\Requests\ApiRequest $request
@param int $version
@param string $resource
@param string|int $id
@return \Illuminate\Http\JsonResponse
handles an item request to a resource