laravel-json-api/core
Contracts and support classes for Laravel JSON:API packages.
v5.3.0
1.8M downloads/mo
#2923 most downloaded on Packagist
laravel-json-api/core
What this package is like to depend on
Last release 4 months ago
28 Mar 2026
Ships fairly regularly
a new release about every 3 months
Nearly every release is documented
notes for 26 of 26 stable releases
Nothing withdrawn
no release was ever pulled
6 years old
36 releases · first in 2021
3 releases in the last 12 months
see the full history below
Release timeline
36 releases · Jan 2021 to Mar 2026
2022
2023
2024
2025
2026
Releases
latest 36-
v5.3.028 Mar 2026 -
v5.2.205 Feb 2026Release notes
Open source →Fixed
- #27 Update UUID regex to be case-insensitive. This also means the regex now matches Laravel's UUID route parameter regex, which is where the regex in this pacakge was originally derived from.
-
v5.2.110 Oct 2025Release notes
Open source →Changed
- Improve exception message when resource container cannot resolve a value to a JSON:API resource.
-
v5.2.024 Feb 2025 -
v5.1.023 Jan 2025 -
v5.0.211 Jan 2025Release notes
Open source →Fixed
- #23 Ensure relationship meta is included in paginated relationship responses.
-
v5.0.130 Nov 2024 -
v5.0.029 Nov 2024Release notes
Open source →Added
- BREAKING: #21 The
Authorizercontract now allows all methods to return aboolor an Illuminate authorization response.
- BREAKING: #21 The
-
v4.3.230 Nov 2024 -
v4.3.129 Nov 2024Release notes
Open source →Fixed
- Reverted #19 as the changes were breaking, so should not have been released as a minor version.
-
v4.3.026 Nov 2024Release notes
Open source →Added
- #19 The
Authorizercontract now allows all methods to return aboolor an authorizer response.
Fixed
- Removed deprecation notices in PHP 8.4.
- #19 The
-
v4.2.021 Aug 2024Release notes
Open source →Added
- Response classes now have a
withoutHeaders()method to remove headers from the response.
Fixed
- #18 Ensure headers are merged when using the
withHeaders()method on the JSON:API response classes. This was previously not merging headers, which was not correct and therefore this is a bug fix. If you were relying on this behaviour, use the newwithoutHeaders()method to remove any headers.
- Response classes now have a
-
v4.1.026 Jun 2024Release notes
Open source →Fixed
- #17 Fix incorrect
selflink in related resource responses, and removerelatedlink that should not exist. This has been incorrect for some time, but is definitely what the spec defines here.
- #17 Fix incorrect
-
v4.0.012 Mar 2024Release notes
Open source →Changed
- Package is now licensed under the MIT License.
- BREAKING Package now requires Laravel 11.
- Minimum PHP version is now
8.2.
-
v3.3.008 Nov 2023Release notes
Open source →Added
- Can now create a JSON:API server once, without it being thread-cached. This is required for registering routes, as we
do not expect that server instance to be used again after routes are registered. This matches production,
where
route:cacheshould have been used, so it would be inaccurate to leave the server thread-cached after registering routes in a non-production environment e.g. test.
- Can now create a JSON:API server once, without it being thread-cached. This is required for registering routes, as we
do not expect that server instance to be used again after routes are registered. This matches production,
where
-
v3.2.020 Jul 2023Release notes
Open source →Added
- #12 Add
ulid()method to the matches ids trait.
Fixed
- #10 Use correct resolver for resource type.
- #12 Add
-
v3.1.012 Mar 2023Release notes
Open source →Added
- #9 Can now cast a
stdClassobject to aHashvia theHash::cast()method.
- #9 Can now cast a
-
v3.0.014 Feb 2023 -
v2.4.015 Jan 2023 -
v2.3.017 Apr 2022Release notes
Open source →Added
- The
JsonApiExceptionnow has acontext()method. The Laravel exception handler uses this to obtain additional context information to log when logging the exception. This method returns the status code and the JSON:API errors so that these can be seen if a JSON:API exception is logged.
- The
-
v2.2.001 Apr 2022Release notes
Open source →Added
- New
Document\ResourceIdentifier::idIsEmpty()static method for checking that anidvalue is not empty. This check ensures that the trimmed string is empty and that the string is not"0", as zero could be used for a resource id. This new static method has been added to ensure the logic of determining if an id value is empty is in one place.
Fixed
- The
Document\ResourceObjectclass now accepts an id of"0". Previously this was treated as empty, which is incorrect.
- New
-
v2.1.020 Feb 2022Release notes
Open source →Added
- The
LazyRelationclass now has anall()method to get the related resources for a to-many relation as an array. - The
LazyRelationclass now caches the to-one resource. Previously it only cached the to-many resources, so this change makes the behaviour consistent.
Fixed
- Previously the
LazyRelationclass would always throw an exception if iterated over. This has now been fixed.
- The
-
v2.0.008 Feb 2022Release notes
Open source →Added
- Package now supports Laravel 9.
- Added two new utility classes -
Support\AppResolverandSupport\ContainerResolver- that lazily resolve the current application and container instances. These have been added to enable support for Laravel Octane, which recommends injecting a closure resolver for getting that current instances of the application or container. These utility classes enable strictly type-hinted constructor dependency injection, as these classes are more specific about what the resolver than just type-hinting the generic\Closureclass which could return anything.
Changed
- Added return types for internal methods, to remove deprecation warnings on PHP 8.1.
- BREAKING: Made the following changes to support Laravel Octane:
- The
Schema\Containerclass now takes an instance ofSupport\ContainerResolveras its first constructor argument. This allows the schema container to lazily load the current container instance. - The
Server\Serverclass now takes an instance ofSupport\AppResolveras its first constructor argument. In addition, the$appproperty has been made private, and the deprecated$containerproperty has been removed. Child classes that need to access either the application or the container should use the new protectedapp()method. This change allows the server instance to lazily load the current application instance. - The
Server\ServerRepositoryclass now only has a single constructor argument, which is an instance ofSupport\AppResolver. The private$configproperty has also been removed. This change allows the server repository to lazily load the current application instance.
- The
-
v1.1.108 Feb 2022Release notes
Open source →Added
- Added a
JsonApiExceptiontest as this class requires breaking changes when upgrading Symfony to the next version.
- Added a
-
v1.1.003 Jan 2022Release notes
Open source →Added
- Relationship response classes now merge relationship links with the links set on the response classes. This can be
disabled by calling the
withoutRelationshipLinks()method on these classes. - The
ConditionalFieldclass now has avalue()method to get the value of the field without checking whether the field is meant to be skipped. - The
ConditionalFieldsclass now has a publicvalues()method to get the values of the fields without checking whether the fields are meant to be skipped. - laravel-#127 The
JsonApiResourceclass now has a protectedserializeRelation()method, that allows a developer to customise the serialization of a JSON:API resource's relationship beyond the default implemented by this package. - The resource
Relationclass now has two additional helper methods:onlySelfLink()andonlyRelatedLink(). - Added new features to the
Linksobject:- It now implements
ArrayAccess. - New
has()method for checking whether a key exists in the links object. - New
hasSelf()andgetSelf()methods for accessing theselflink defined by the JSON:API spec. - New
hasRelated()andgetRelated()methods for accessing therelatedlink defined by the JSON:API spec. - New
all()method for getting the links as an array.
- It now implements
Fixed
- laravel-#130 The
JsonApiResource::relationship()method now safely iterates over relationships even if they are conditional. This means the named relationship will always be found even if it is marked to be skipped when serializing the resource. This is implemented through a newRelationIteratorclass. - laravel-#105 The relationship response classes now handle the relationship not existing on the resource. This can happen if a developer has marked the relationship as hidden. While it is not recommended to hide relationships that have relationship endpoints, this gracefully handles this scenario when merging links and meta into the top-level document response.
- Relationship response classes now merge relationship links with the links set on the response classes. This can be
disabled by calling the
-
v1.0.031 Jul 2021Release notes
Open source →Fixed
- Ensure the
DataResponseclass passes on its created flag if its data member is already aJsonApiResource. - Only add the
Locationheader to a response if the resource has aselfURL. Previously the header would be set with anullvalue.
- Ensure the
-
v1.0.0-beta.510 Jul 2021 pre-releaseRelease notes
Open source →Added
- #6 The authorizer contract now has a
showRelatedmethod to authorize the show-related controller action. Previously theshowRelationshipmethod was used to authorize both the show-related and show-relationship controller actions. This change means that authorizers can implement different authorization logic if needed. However, our default authorizer (theAuth\Authorizerclass) remains unchanged in that both actions expect there to be aview<RelationshipName>method on the policy to authorize these actions. - The
JsonApiExceptionclass now hasis4xx()andis5xx()helper methods for determining whether the HTTP status code is in the 4xx or 5xx range.
Changed
- The
Schema\Schemaclass no longer sorts fields by their name. This means fields are now processed in the order that they are defined by the developer. Fields can be listed in alphabetical order by the developer if that is the desired order. - The
Auth\Authorizerclass is no longerfinaland can now be extended if needed. - Moved the package JSON:API version to a constant on the
JsonApiServiceclass.
- #6 The authorizer contract now has a
-
v1.0.0-beta.402 Jun 2021 pre-releaseRelease notes
Open source →Changed
- BREAKING Removed the iterable type-hint from the
Contracts\Pagination\Page::withQuery()method. The value passed can be any value that can be cast to aCore\Query\QueryParametersobject. This change also affects theCore\Pagination\AbstactPage::withQuery()method, that has been updated to remove the type-hint. This will affect any child classes that have overloaded this method. - BREAKING Remove the iterable type-hint from the
Core\Resources\ResourceCollection::withQuery()method. The value passed can be any value that can be cast to aCore\Query\QueryParametersobject.
Fixed
- Ensure internal response classes all consistently use the
links()method when passing links to the encoder. This fixes a bug whereby pagination links were not added to the compound document for related resources and relationship identifier responses. - Query parameters passed to the abstract page object were not correctly encoding to a query string. This is because the
collect()method was being used, which meantQueryParameters::toArray()would be used to serialize query parameters. This has now been updated to useQueryParameters::toQuery()instead, which is the correct method to use.
- BREAKING Removed the iterable type-hint from the
-
v1.0.0-beta.326 Apr 2021 pre-releaseRelease notes
Open source →Added
- Include paths and sparse field sets that should be used when encoding JSON:API responses can now be manually set on
response classes using the
withIncludePaths()andwithSparseFieldSets()methods, or using the conveniencewithQueryParameters()method to set both from a query parameters object. When include paths and/or sparse field sets are set on the response, these are used when encoding the response JSON instead of determining these query parameters from the request. If no include paths or sparse field sets are set on the response, the previous behaviour of determining these from the request is used.
Changed
- BREAKING Methods relating to include paths and sparse field sets have been moved from the
Responses\Concerns\IsResponsabletrait to a newResponses\Concerns\HasEncodingParameterstrait. As part of this change, the previousprotectedmethodfieldSets()has been renamedsparseFieldSets(). - BREAKING Made several changes to interfaces for sort fields:
- The
AttributeandIDinterfaces no longer implementSortableand instead have aisSortable()method directly defined on their interface. - The
Sortableinterface is now intended to be implemented on a class that is an additional sort field to those that are attributes. It has one method:sortField()which returns the name of the sort field. - The
Schema::isSortable()method has been renamedisSortField(). This makes it clearer that the method is querying whether the provided name is a valid sort field. - The
Schema::sortable()method has been renamedsortFields(). This makes it clearer that the method is returning a list of the sort field names. - Added the
sortField()andsortables()methods to theSchemainterface.
- The
- Include paths and sparse field sets that should be used when encoding JSON:API responses can now be manually set on
response classes using the
-
v1.0.0-beta.220 Apr 2021 pre-releaseRelease notes
Open source →Added
- The schema container now supports resolving schemas for models where the schema is registered against a parent class or interface. Parent classes are matched before interfaces, and if a match is found the resolution is cached to ensure the resolution logic runs once per model class.
- The resource factory class now looks up schemas for a model first, then retrieves the fully-qualified resource class from the matched schema. By delegating to the schema like this, the resource container can now convert models to resources where a schema has been registered for a parent class or interface.
- The
Contracts\Resources\Factoryinterface now has acanCreate()method to determine whether the factory can create a JSON:API resource for the supplied model. - The
Contracts\Schema\Containerinterface now has aexistsForModel()method, to determine whether a schema exists for the supplied model class.
Changed
- The
Core\Resources\Containerclass now expects a single factory instance to its constructor. This was changed as there was no requirement for multiple resource factories to be loaded into the container. The container still supports injecting a factory, as this allows the creation of resources by the container to be customised, without having to re-implement the logic within the container class. As part of this change, theContainer::attach()method was also removed. - The
Core\Resources\Factoryclass constructor was amended to only expect a schema container. Additionally the method signature of the protectedbuild()method was changed to receive a schema instance and the model being converted to a JSON:API resource. - The
Core\Server\ServerandCore\Server\ServerRepositoryclasses are now injected with the Laravel application instance, instead of just type-hinting the container. This change was made to allow code within servers to access the application environment, using$this->app->environment()rather than having to useapp()->environment()(which used to be the case as the injection was only type-hinted as the container contract).
Fixed
- The base
Serverclass now correctly passes extra parameters in itsurl()method. Previously these were passed to Laravel'surl()helper - but that helper only appends extra parameters if there is no HTTP host in the provided path. The server'surl()method now passes these as we always went them appended, regardless of whether the API's base path has a HTTP host or not. - Include paths, sort fields and countable paths now correctly parse empty values. Previously an error was caused by attempting to cast an empty string to the relevant query objects.
Deprecated
- The
Core\Server\Server::$containerproperty is deprecated and will be removed in1.0.0-stable. Child classes should use the newServer::$appproperty instead.
Removed
- The
Contracts\Resources\Factory::handles()method has been removed in favour of using the newcanCreate()method instead. - The
Contracts\Schema\Container::resources()method has been removed, in favour of resource factories using the schema container'sexistsForModel()andschemaForModel()methods.
-
v1.0.0-beta.130 Mar 2021 pre-releaseRelease notes
Open source →Added
- BREAKING Added the following methods to the
Contracts\Schema\Schemainterface:isFilter(),isSparseField,isSortable()andhasSelfLink(). These methods have been added to the abstract schema class provided by this package, so this is unlikely to have a significant impact on implementing packages. - BREAKING Made the following changes to the
Contracts\Query\QueryParametersinterface:- New
unrecognisedParametersmethod. This returns any query parameters that are not defined by the JSON:API specification, which allows implementations to add support for additional query parameters as needed. - The
filtersmethod now returns aFilterParametersobject or null. Previously it returned an array or null.
- New
- BREAKING The
$baseUriargument on theContracts\Resources\Serializer\Relationinterface is now nullable. - BREAKING The
Contracts\Store\Storeinterface now has afindOrFailmethod. This is unlikely to be breaking in most implementations because theCore\Store\Storeclass will be in use and has been updated. - BREAKING Added a
castmethod to theContracts\Resources\Containerinterface. This is unlikely to be breaking in most implementations because theCore\Resources\Containerclass will be in use and has been updated. - New
Contracts\Schema\IdEncoderinterface to encode model IDs to JSON:API resource IDs. - New
FilterParametersclass for handling a collection of filter parameters received from a client. - The
FieldSets,IncludePathsandSortFieldsclasses all now have acollect()method, that returns a collection object. - The
IncludePathsandSortFieldsclasses now havefilter,rejectandforSchemamethods. - The
SortFieldclass now has staticascendinganddescendingmethods, to easily create a sort field with the specified direction. - The
QueryParametersclass now has atoQuery()method, that casts the value back to a HTTP query parameter array. This is different fromQueryParameters::toArray(), as theincludeandsortparameters are strings in a HTTP query array. - The
QueryParametersclass now has aforSchema()method, that returns a new query parameters instance that contains only parameters valid for the supplied schema. - The
Document\ResourceObjectclass has a newwithRelationshipMetamethod for adding meta for a specified relationship. - Added new response classes for returning related resources for a relationship - e.g. the
/api/posts/1/commentsendpoint. Previously theDataResponseclass was used for this endpoint, but the new classes allow for relationship meta to be merged into the top-level meta member of the response for the endpoint. - The core package now supports the countable implementation-semantic. This adds a custom query parameter that allows a client to specify which relationships should have a count added to their relationship meta.
- Added a number of pagination traits -
HasPageMetaandHasPageNumbers, so that these can be used in both the Eloquent and non-Eloquent implementations. - Added a
dumpmethod to theCore\Document\ResourceObjectclass.
Changed
- BREAKING The return type of
Contracts\Schema\Schema::repository()is now nullable. - BREAKING The return type of
Contracts\Store\Store::resources()is now nullable. - BREAKING Made a number of changes to store contracts, so that the contracts are easier to implement in when not
working with Eloquent resources:
- The
QueryAllBuildercontract has been removed; support for singular filters is now implemented via theHasSingularFiltersinterface which is intended to be added to classes implementingQueryManyBuilder. As part of this change, theQueriesAll::queryAll()method now has theQueryManyBuilderinterface as its return type. - The
QueryManyBuildercontract no longer has pagination methods on it. If a builder supports pagination, it must add theHasPaginationinterface. - Removed the
cursormethod from theQueryManyBuildercontract, as it is not required on the contract (implementing classes can add it if needed). Thegetmethod now has a return type ofiterableinstead of the LaravelCollectionclass.
- The
- BREAKING The
Contracts\Encoder\Encoderinterface now has two methods for encoding resource identifiers:withToOneandwithToMany. These replace thewithIdentifiersmethod, which has been removed. - Moved the following classes from the
Core\Responsesnamespace to theCore\Responses\Internalnamespace. This is considered non-breaking because the classes are not part of the public API (responses that can be used for the public API are still in theCore\Responsesnamespace):PaginatedResourceResponseResourceCollectionResponseResourceIdentifierCollectionResponseResourceIdentifierResponseResourceResponse
Removed
- Deleted the
Core\Responses\Concerns\EncodesIdentifierstrait. This is considered non-breaking as the trait was only intended for internal use.
Fixed
- The
QueryParameters::setFieldSet()method now correctly passes the fields lists as an array to the field set constructor. - Fixed the
Core\Document\ResourceObject::merge()method handling of merging relationships. Previously this usedarray_replace_recursiveto megre the relationship object, but this led to incorrect merging ofdatamembers, particularly for to-many relationships. This has been altered toarray_replace, so that thedata,linksandmetamembers of the relationship are replaced with the values from the resource object's relationship that is being merged in.
- BREAKING Added the following methods to the
-
v1.0.0-alpha.512 Mar 2021 pre-releaseRelease notes
Open source →Added
- If closures are used for data and/or meta on the
Resources\Relationclass, the closures will now receive the model as their first and only argument. - The default value of the
Resources\Relationclass is now returned by a protectedvaluemethod, allowing child classes to modify the default behaviour if needed. - New
Creatableinterface, which theJsonApiResourceclass delegates to when determining whether a resource was created within the current HTTP request.
Changed
- The
$containerproperty on theServerclass is nowprotectedand can be used by child classes if needed. - The
$resourceproperty on theResources\Relationclass is nowprotected.
Removed
- Reverted #3 Server classes can no longer use constructor dependency injection. This is because server classes are created in a number of different contexts - e.g. HTTP requests, Artisan generators, etc - so injecting dependencies via the constructor will likely result in developers injecting dependencies that are only required in certain contexts in which the server is being used. See laravel #44 for discussion on this topic.
- The
Server\Servercontract no longer has aserving()method on it. This has been removed from the contract so that developers can type-hint dependencies in theirservingmethod.
- If closures are used for data and/or meta on the
-
v1.0.0-alpha.427 Feb 2021 pre-releaseRelease notes
Open source →Added
- BREAKING The builder interfaces in the
Contracts\Storenamespace now have awithRequestmethod. This allows passing the request into the builder process as context for the action. - BREAKING The
Contracts\Routing\Routecontract now has anauthorizermethod, for getting the authorizer instance for the route. - BREAKING The
Contracts\Schema\Schemacontract now has aurlmethod, for generating a URL for the resource that the schema defines. - BREAKING Added the
allInverse()method to theContracts\Schema\Relationcontract. This returns a list of the allowed resource types for the relationship. Typically this will just be one resource type; polymorphic relations will return multiple. - New
getmethod on theConditionalFieldclass for retrieving the value of the field. - Response classes now have a
withServermethod, for explicitly setting the JSON:API server to use when generating the response. This is useful when returning responses from routes that do not have the JSON:API middleware applied to them. - New
MetaResponseclass for returning a JSON:API response with a document containing a top-levelmetavalue. - #3 Server classes are now resolved via the service container, allowing the developer to use constructor dependency injection if desired.
- The
DataResponseclass now has adidntCreatemethod for ensure the resource response does not have a201 Createdstatus.
Changed
- BREAKING The
Contracts\Auth\Authorizercontract now requires the model class to be passed as the second argument on theindexandstoremethods. Also, all methods have been updated to type-hint the Illuminate request object. - BREAKING The
usingmethod has been renamed towithQueryon the following interfaces in theContracts\Storenamespace:QueryManyBuilderQueryOneBuilderResourceBuilderToManyBuilderToOneBuilder
- BREAKING The
Contracts\Resources\Serializer\Hideablecontract has been updated to type-hint the request class in its method signatures. - BREAKING The
Core\Schema\SchemaAwaretrait has been moved to theCore\Schema\Concernsnamespace, for consistency with other traits. - BREAKING The
Core\Schema\Containerclass now expects the server instance to be passed as its second constructor argument, with the list of schemas now its third constructor argument. - BREAKING The constructor argument for the abstract
Core\Schema\Schemaclass has been changed to the server instance that the schema belongs to. This change was made so that schemas can generate URLs using the server instance, while also injecting the server's schema container into fields if needed. - The server repository now caches servers it has created, and should now be registered in the service container as a singleton.
Fixed
- Fixed parsing the
fieldsquery parameter to theCore\Query\FieldSetsandCore\Query\FieldSetclasses.
- BREAKING The builder interfaces in the
-
v1.0.0-alpha.309 Feb 2021 pre-releaseRelease notes
Open source →Added
- BREAKING The
Contracts\Schema\Relationcontract now has aisValidated()method, to determine if the relation value should be merged when validating update requests. There is now aCore\Schema\Concerns\RequiredForValidationtrait that can be used on relationship fields to implement the required method. - New features for the
Core\Documents\ResourceObjectclass:- New
merge()method for merging two resource objects together. This is useful for update validation, where the values supplied by a client need to be merged over the existing resource field values. - The
putRelationandreplacemethods now accept an instance ofUrlRoutablefor theidvalue of to-one or to-many relations.
- New
- The schema container instance is now injected into schema classes via the constructor
$schemasproperty. This has been added so that a schema class can be instantiated directly from the service container if the schema container is bound in the service container. - New
Core\Resources\ConditionalListclass, for iterating over conditional attributes but yielding them as a zero-indexed array list.
Changed
- The
Core\Document\ResourceObject::withoutLinks()method now correctly removes both resource links and relationship links. - BREAKING As conditional values are now supported in relationships (previously only supported in attributes), the
following have been renamed to make it clear that they are not just for use in attributes:
- The
Core\Resources\Concerns\ConditionallyLoadsAttributestrait is nowConditionallyLoadsFields. - The
Core\Resources\ConditionalAttris nowConditionalField. - The
Core\Resources\ConditionalAttrsis nowConditionalFields.
- The
- BREAKING The first argument on the
Contracts\Server\Serverinterface ($parameters) has been made optional.
Removed
- BREAKING Removed the
mustValidate()andisValidated()methods from theCore\Resources\Relationclass. These fields are now defined on the schema's relation field instead of the resource's relation. - BREAKING Made changes to the
Core\Documents\ResourceObjectclass:- Removed the deprecated
create()method, as this was never intended to be brought in from the old package. - Remove the
Arrayablecontract (and therefore thetoArray()method). This is becausetoArray()was always ambiguous - would it return the field values, or the JSON representation of the resource? ReplacetoArray()withjsonSerialize(). Theall()method continues to return the field values.
- Removed the deprecated
- BREAKING The
-
v1.0.0-alpha.202 Feb 2021 pre-releaseRelease notes
Open source →Added
- #2
BREAKING The
Core\Resources\JsonApiResourceis no longer abstract, and now expects the schema and the model to be injected via its constructor. It will use the schema to convert a model to a JSON:API resource. This allows the resource classes to be optional, as the resource resolution logic can now fall-back to theJsonApiResourcewhen no specific resource class exists. Schema fields must implement theContracts\Resources\Serializer\AttributeandContracts\Resources\Serializer\Relationinterfaces on their fields for the serialization to work. - BREAKING The
Contracts\Encoder\Encodercontract now has awithRequestmethod to inject the current HTTP request into the encoding process. The response classes have been updated to pass the request through to the encoder in theirtoResponse()methods. - BREAKING The
Contracts\Schema\Containercontract now has aschemaForModelmethod to lookup a schema by providing either a model instance, or the fully-qualified class name of a model. - BREAKING The
Contracts\Schema\IDcontract now has akey()method, that can return the model key for the ID. - BREAKING The
Contracts\Schema\Schemacontract now has new methods:uriType()which returns the resource type as it appears in URIs.idKeyName()which returns the object key for theidvalue.
- New
Contracts\Resources\JsonApiRelationcontract for the relation object returned by theJsonApiResource::relationships()method. This has the methods on it that encoders can rely on when encoding the relationship to JSON. - BREAKING The
Contracts\Schema\Relationcontract now has auriName()method for retrieving the relationship's field name as it appears in a URI. TheJsonApiResourceclass now automatically injects this value from the schema field into the resource relation object. - New
Core\Resources\ConditionalIteratorclass for iterating over values that could contain conditional attributes.
Changed
- BREAKING The
attributes,relationships,metaandlinksmethod of theJsonApiResourceclass now require the request to be passed as a parameter. This is to bring the resource in line with Laravel's Eloquent resource, though our implementation allows the request to benullto cater for resource encoding outside of HTTP requests (e.g. queued broadcasting). Additionally, therelationshipmethod return type has been changed to the newContracts\Resources\JsonApiResourcecontract. - BREAKING The
existsandcreatemethods on theContracts\Resources\Containercontract now correctly type-hint the parameter as anobject. - BREAKING The
createResourcemethod on theContracts\Resources\Factorycontract now correctly type-hints the parameter as anobject. - BREAKING The constructor of the
Core\Resources\Factoryclass now expects a schema container and an optional array of resource bindings (instead of an iterable). If anullvalue is provided for the bindings, the bindings will be retrieved from the schema container. Additionally, the protectedbuildmethod signature has been updated to correctly type-hint the second argument as anobject. - BREAKING The constructor arguments for the
Core\Resources\Relationclass have been changed so that it now receives the model and base URI - rather than theJsonApiResourceobject. This change was made so that it can be used more broadly.
Removed
- BREAKING The
attachandattachAllmethods of theCore\Resources\Factoryclass have been removed, because they were not in use.
- #2
BREAKING The
-
v1.0.0-alpha.125 Jan 2021 pre-release