Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: laravel-json-api/laravel
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.5.2
Choose a base ref
...
head repository: laravel-json-api/laravel
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: develop
Choose a head ref
Loading
Showing with 1,676 additions and 2,126 deletions.
  1. +13 −10 .github/workflows/tests.yml
  2. +1 −1 .gitignore
  3. +122 −0 CHANGELOG.md
  4. +21 −202 LICENSE
  5. +2 −2 README.md
  6. +13 −13 composer.json
  7. +13 −12 phpunit.xml
  8. +50 −0 src/Console/Concerns/ReplacesModel.php
  9. +4 −12 src/Console/Concerns/ResolvesStub.php
  10. +4 −12 src/Console/GeneratorCommand.php
  11. +4 −12 src/Console/MakeAuthorizer.php
  12. +4 −12 src/Console/MakeController.php
  13. +4 −12 src/Console/MakeFilter.php
  14. +4 −12 src/Console/MakeQuery.php
  15. +4 −12 src/Console/MakeRequest.php
  16. +4 −12 src/Console/MakeRequests.php
  17. +19 −13 src/Console/MakeResource.php
  18. +9 −30 src/Console/MakeSchema.php
  19. +4 −12 src/Console/MakeServer.php
  20. +4 −12 src/Console/MakeSortField.php
  21. +4 −12 src/Console/StubPublish.php
  22. +6 −14 src/Exceptions/HttpNotAcceptableException.php
  23. +4 −12 src/Exceptions/HttpUnsupportedMediaTypeException.php
  24. +4 −12 src/Facades/JsonApiRoute.php
  25. +4 −12 src/Http/Controllers/Actions/AttachRelationship.php
  26. +37 −16 src/Http/Controllers/Actions/Destroy.php
  27. +4 −12 src/Http/Controllers/Actions/DetachRelationship.php
  28. +4 −12 src/Http/Controllers/Actions/FetchMany.php
  29. +4 −12 src/Http/Controllers/Actions/FetchOne.php
  30. +4 −12 src/Http/Controllers/Actions/FetchRelated.php
  31. +4 −12 src/Http/Controllers/Actions/FetchRelationship.php
  32. +4 −12 src/Http/Controllers/Actions/Store.php
  33. +4 −12 src/Http/Controllers/Actions/Update.php
  34. +4 −12 src/Http/Controllers/Actions/UpdateRelationship.php
  35. +4 −12 src/Http/Controllers/JsonApiController.php
  36. +4 −12 src/Http/Middleware/BootJsonApi.php
  37. +4 −12 src/Http/Requests/AnonymousCollectionQuery.php
  38. +4 −12 src/Http/Requests/AnonymousQuery.php
  39. +45 −37 src/Http/Requests/FormRequest.php
  40. +4 −12 src/Http/Requests/RequestResolver.php
  41. +7 −14 src/Http/Requests/ResourceQuery.php
  42. +7 −14 src/Http/Requests/ResourceRequest.php
  43. +4 −12 src/LaravelJsonApi.php
  44. +4 −12 src/Routing/ActionProxy.php
  45. +12 −20 src/Routing/ActionRegistrar.php
  46. +26 −15 src/Routing/PendingRelationshipRegistration.php
  47. +20 −17 src/Routing/PendingResourceRegistration.php
  48. +4 −12 src/Routing/PendingServerRegistration.php
  49. +12 −13 src/Routing/Registrar.php
  50. +24 −14 src/Routing/RelationshipRegistrar.php
  51. +4 −12 src/Routing/Relationships.php
  52. +26 −16 src/Routing/ResourceRegistrar.php
  53. +4 −12 src/Routing/Route.php
  54. +4 −12 src/ServiceProvider.php
  55. +21 −20 stubs/authorizer.stub
  56. +6 −2 stubs/resource.stub
  57. +4 −12 tests/dummy/app/Http/Controllers/Api/V1/PostController.php
  58. +5 −12 tests/dummy/app/Http/Controllers/Api/V1/UserController.php
  59. +4 −12 tests/dummy/app/Http/Controllers/Api/V1/VideoController.php
  60. +4 −12 tests/dummy/app/Http/Controllers/Controller.php
  61. +4 −12 tests/dummy/app/JsonApi/V1/Comments/CommentSchema.php
  62. +4 −12 tests/dummy/app/JsonApi/V1/Images/ImageSchema.php
  63. +4 −12 tests/dummy/app/JsonApi/V1/Media/MediaCollectionQuery.php
  64. +4 −12 tests/dummy/app/JsonApi/V1/Phones/PhoneSchema.php
  65. +4 −12 tests/dummy/app/JsonApi/V1/Posts/PostCollectionQuery.php
  66. +4 −12 tests/dummy/app/JsonApi/V1/Posts/PostQuery.php
  67. +4 −12 tests/dummy/app/JsonApi/V1/Posts/PostRequest.php
  68. +14 −16 tests/dummy/app/JsonApi/V1/Posts/PostSchema.php
  69. +4 −12 tests/dummy/app/JsonApi/V1/Posts/PostScope.php
  70. +4 −12 tests/dummy/app/JsonApi/V1/Server.php
  71. +4 −12 tests/dummy/app/JsonApi/V1/Tags/TagSchema.php
  72. +4 −12 tests/dummy/app/JsonApi/V1/Users/UserQuery.php
  73. +4 −12 tests/dummy/app/JsonApi/V1/Users/UserRequest.php
  74. +4 −12 tests/dummy/app/JsonApi/V1/Users/UserSchema.php
  75. +4 −12 tests/dummy/app/JsonApi/V1/Videos/VideoRequest.php
  76. +4 −12 tests/dummy/app/JsonApi/V1/Videos/VideoSchema.php
  77. +4 −12 tests/dummy/app/Models/Comment.php
  78. +4 −12 tests/dummy/app/Models/Image.php
  79. +4 −12 tests/dummy/app/Models/Phone.php
  80. +4 −12 tests/dummy/app/Models/Post.php
  81. +4 −12 tests/dummy/app/Models/Tag.php
  82. +4 −12 tests/dummy/app/Models/User.php
  83. +4 −12 tests/dummy/app/Models/Video.php
  84. +4 −12 tests/dummy/app/Policies/PostPolicy.php
  85. +25 −0 tests/dummy/app/Policies/TagPolicy.php
  86. +18 −12 tests/dummy/app/Policies/UserPolicy.php
  87. +4 −12 tests/dummy/app/Policies/VideoPolicy.php
  88. +4 −12 tests/dummy/app/Providers/AppServiceProvider.php
  89. +4 −12 tests/dummy/app/Providers/AuthServiceProvider.php
  90. +4 −12 tests/dummy/app/Providers/EventServiceProvider.php
  91. +4 −12 tests/dummy/app/Providers/RouteServiceProvider.php
  92. +4 −12 tests/dummy/config/jsonapi.php
  93. +4 −12 tests/dummy/database/factories/CommentFactory.php
  94. +4 −12 tests/dummy/database/factories/ImageFactory.php
  95. +4 −12 tests/dummy/database/factories/PhoneFactory.php
  96. +4 −12 tests/dummy/database/factories/PostFactory.php
  97. +4 −12 tests/dummy/database/factories/TagFactory.php
  98. +4 −12 tests/dummy/database/factories/UserFactory.php
  99. +4 −12 tests/dummy/database/factories/VideoFactory.php
  100. +4 −12 tests/dummy/database/migrations/2020_06_13_143800_create_post_and_video_tables.php
  101. +4 −12 tests/dummy/database/migrations/2022_06_25_115000_create_phones_table.php
  102. +8 −13 tests/dummy/routes/api.php
  103. +4 −12 tests/dummy/routes/web.php
  104. +4 −12 tests/dummy/tests/Api/V1/Posts/Actions/PublishTest.php
  105. +4 −12 tests/dummy/tests/Api/V1/Posts/Actions/PurgeTest.php
  106. +4 −12 tests/dummy/tests/Api/V1/Posts/AttachMediaTest.php
  107. +4 −12 tests/dummy/tests/Api/V1/Posts/AttachTagsTest.php
  108. +4 −12 tests/dummy/tests/Api/V1/Posts/CreateTest.php
  109. +20 −12 tests/dummy/tests/Api/V1/Posts/DeleteTest.php
  110. +4 −12 tests/dummy/tests/Api/V1/Posts/DetachMediaTest.php
  111. +4 −12 tests/dummy/tests/Api/V1/Posts/DetachTagsTest.php
  112. +51 −15 tests/dummy/tests/Api/V1/Posts/IndexTest.php
  113. +4 −12 tests/dummy/tests/Api/V1/Posts/ReadAuthorIdentifierTest.php
  114. +8 −17 tests/dummy/tests/Api/V1/Posts/ReadAuthorTest.php
  115. +4 −12 tests/dummy/tests/Api/V1/Posts/ReadCommentIdentifiersTest.php
  116. +6 −19 tests/dummy/tests/Api/V1/Posts/ReadCommentsTest.php
  117. +4 −12 tests/dummy/tests/Api/V1/Posts/ReadMediaTest.php
  118. +4 −12 tests/dummy/tests/Api/V1/Posts/ReadTagIdentifiersTest.php
  119. +9 −16 tests/dummy/tests/Api/V1/Posts/ReadTagsTest.php
  120. +4 −12 tests/dummy/tests/Api/V1/Posts/ReadTest.php
  121. +4 −12 tests/dummy/tests/Api/V1/Posts/UpdateMediaTest.php
  122. +4 −12 tests/dummy/tests/Api/V1/Posts/UpdateTagsTest.php
  123. +5 −13 tests/dummy/tests/Api/V1/Posts/UpdateTest.php
  124. +4 −12 tests/dummy/tests/Api/V1/Serializer.php
  125. +50 −0 tests/dummy/tests/Api/V1/Tags/DeleteTest.php
  126. +5 −13 tests/dummy/tests/Api/V1/TestCase.php
  127. +49 −0 tests/dummy/tests/Api/V1/Users/DeleteTest.php
  128. +4 −12 tests/dummy/tests/Api/V1/Users/ReadTest.php
  129. +4 −12 tests/dummy/tests/Api/V1/Users/UpdatePhoneTest.php
  130. +4 −12 tests/dummy/tests/Api/V1/Videos/CreateTest.php
  131. +4 −12 tests/dummy/tests/TestCase.php
  132. +4 −12 tests/lib/Acceptance/DefaultIncludePaths/Test.php
  133. +4 −12 tests/lib/Acceptance/DefaultIncludePaths/TestRequest.php
  134. +56 −21 tests/lib/Acceptance/Relationships/ToManyLinksTest.php
  135. +54 −21 tests/lib/Acceptance/Relationships/ToOneLinksTest.php
  136. +5 −12 tests/lib/Acceptance/RequestBodyContentTest.php
  137. +4 −12 tests/lib/Acceptance/ResponseTest.php
  138. +4 −12 tests/lib/Acceptance/TestCase.php
  139. +4 −12 tests/lib/Integration/Console/MakeAuthorizerTest.php
  140. +4 −12 tests/lib/Integration/Console/MakeControllerTest.php
  141. +4 −12 tests/lib/Integration/Console/MakeFilterTest.php
  142. +4 −12 tests/lib/Integration/Console/MakeQueryTest.php
  143. +4 −12 tests/lib/Integration/Console/MakeRequestTest.php
  144. +4 −12 tests/lib/Integration/Console/MakeRequestsTest.php
  145. +39 −14 tests/lib/Integration/Console/MakeResourceTest.php
  146. +4 −12 tests/lib/Integration/Console/MakeSchemaTest.php
  147. +4 −12 tests/lib/Integration/Console/MakeServerTest.php
  148. +4 −12 tests/lib/Integration/Console/MakeSortFieldTest.php
  149. +4 −12 tests/lib/Integration/Console/StubPublishTest.php
  150. +5 −13 tests/lib/Integration/Routing/ActionsTest.php
  151. +92 −18 tests/lib/Integration/Routing/HasManyTest.php
  152. +91 −21 tests/lib/Integration/Routing/HasOneTest.php
  153. +102 −18 tests/lib/Integration/Routing/ResourceTest.php
  154. +7 −15 tests/lib/Integration/Routing/TestCase.php
  155. +4 −12 tests/lib/Integration/TestCase.php
  156. +4 −12 tests/lib/Unit/PackageTest.php
23 changes: 13 additions & 10 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -2,9 +2,15 @@ name: Tests

on:
push:
branches: [ main, develop ]
branches:
- main
- develop
- 3.x
pull_request:
branches: [ main, develop ]
branches:
- main
- develop
- 3.x

jobs:
build:
@@ -14,15 +20,12 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [7.4, '8.0', 8.1, 8.2]
laravel: [8.76, 9]
exclude:
- php: 7.4
laravel: 9
php: [ 8.2, 8.3, 8.4 ]
laravel: [ 11, 12 ]

steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
@@ -31,13 +34,13 @@ jobs:
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd
tools: composer:v2
coverage: none
ini-values: error_reporting=E_ALL
ini-values: error_reporting=E_ALL, zend.assertions=1

- name: Set Laravel Version
run: composer require "laravel/framework:^${{ matrix.laravel }}" --no-update

- name: Install dependencies
uses: nick-fields/retry@v2
uses: nick-fields/retry@v3
with:
timeout_minutes: 5
max_attempts: 5
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/dummy
vendor/
composer.lock
.phpunit.result.cache
.phpunit.cache/
122 changes: 122 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,128 @@
All notable changes to this project will be documented in this file. This project adheres to
[Semantic Versioning](http://semver.org/) and [this changelog format](http://keepachangelog.com/).

## Unreleased

## [5.1.0] - 2025-02-24

### Added

- Package now supports Laravel 12.

## [5.0.2] - 2025-12-03

### Fixed

- [#302](https://github.com/laravel-json-api/laravel/pull/302) Ensure auth response is used when deleting a resource
that does not have a resource response class.

## [5.0.1] - 2025-12-02

### Fixed

- [#301](https://github.com/laravel-json-api/laravel/pull/301) Do not override response status when authorization
exception is thrown.

## [5.0.0] - 2025-12-01

### Changed

- [#298](https://github.com/laravel-json-api/laravel/pull/298)
and [#70](https://github.com/laravel-json-api/laravel/issues/70) The authorizer implementation now allows methods to
return either `bool` or an Illuminate Auth `Response`.
- **BREAKING** The return type for the `authorizeResource()` method on both resource and query request classes has
changed to `bool|Response` (where response is the Illuminate Auth response). If you are manually calling this method
and relying on the return value being a boolean, this change is breaking. However, the vast majority of applications
should be able to upgrade without any changes.

## [4.1.1] - 2024-11-30

### Fixed

- Remove deprecation notices in PHP 8.4.

## [4.1.0] - 2024-06-26

### Fixed

- [core#17](https://github.com/laravel-json-api/core/pull/17) Fix incorrect `self` link in related resource responses,
and remove `related` link that should not exist. This has been incorrect for some time, but is definitely what
the [spec defines here.](https://jsonapi.org/format/1.0/#document-top-level)
- [eloquent#36](https://github.com/laravel-json-api/eloquent/pull/36) Support Eloquent dynamic relationships.

## [4.0.0] - 2024-03-14

### Changed

- Package is now licensed under the MIT License.
- **BREAKING** Package now requires Laravel 11.
- Minimum PHP version is now `8.2`.

## [3.4.0] - 2024-03-03

### Added

- [#272](https://github.com/laravel-json-api/laravel/pull/272) Added a model property type-hint to the resource stub and
allowed it to be replaced via a model option on the command.

## [3.3.0] - 2024-02-14

### Added

- [#265](https://github.com/laravel-json-api/laravel/issues/265) Allow registration of middleware per action on both
resource routes and relationship routes.

## [3.2.0] - 2023-11-08

### Added

- Exceptions converted to JSON:API errors when debug mode is on now include all previous exceptions.

### Changed

- Registering routes no longer results in the server instance being thread-cached. This more accurately reflects
production environments, where routes would be cached so there would be no thread-cached JSON:API server when handling
a HTTP request. This means tests (and development environments where routes are not cached) more accurately behave in
the same way as production environments.
- Exceptions thrown during the encoding process are no longer caught and re-thrown as previous exceptions. This is due
to the number of questions we receive from developers who do not check previous exceptions, despite exception messages
stating that there is a previous exception to look at.

## [3.1.0] - 2023-07-20

### Added

- [core#12](https://github.com/laravel-json-api/core/pull/12) Add `ulid()` method to the `ID` field class.

## [3.0.0] - 2023-02-14

### Changed

- Upgraded to Laravel 10 and set minimum PHP version to `8.1`.
- **BREAKING** If using the `laravel-json-api/cursor-pagination` package, you now need to passed the schema's `id` field
to the paginator's `make()` method. I.e. use `CursorPagination::make($this->id())`

### Fixed

- **BREAKING** [#190](https://github.com/laravel-json-api/laravel/issues/190) The JSON:API media type now needs to be
sent in the `Accept` header for a "delete" resource request. Previously there was no checking of the `Accept` media
type, so anything could be sent. This is incorrect as the JSON:API specification shows the `Accept` header as
`application/vnd.api+json` for [delete resource requests.](https://jsonapi.org/format/#crud-deleting)

## [2.6.0] - 2023-02-09

### Added

- New `MultiPaginator` that allows a schema to offer multiple different pagination strategies.

### Fixed

- The JSON:API rule validators for the follow query parameter fields all errored if a non-array value was provided. This
is now fixed:
- `fields`
- `page`
- `filter`

## [2.5.2] - 2023-01-25

### Fixed
Loading