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: Ark4ne/laravel-json-api
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.0.1
Choose a base ref
...
head repository: Ark4ne/laravel-json-api
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 6,462 additions and 899 deletions.
  1. +55 −0 .github/workflows/php.yml
  2. +0 −17 .travis.yml
  3. +60 −0 CHANGELOG-1.1.md
  4. +14 −0 CHANGELOG-1.2.md
  5. +38 −0 CHANGELOG-1.3.md
  6. +41 −0 CHANGELOG-1.4.md
  7. +5 −0 CHANGELOG-1.5.md
  8. +674 −0 LICENSE
  9. +15 −7 composer.json
  10. +87 −0 config/jsonapi.php
  11. +14 −0 phpstan.neon
  12. +26 −0 phpunit.php8.1.xml.dist
  13. +26 −0 phpunit.php8.2.xml.dist
  14. +26 −0 phpunit.php8.3.xml.dist
  15. +26 −0 phpunit.php8.4.xml.dist
  16. +19 −22 phpunit.xml.dist
  17. +217 −62 readme.md
  18. +55 −0 src/Asserts/AssertJsonApiResource.php
  19. +13 −0 src/Asserts/EagerSetAttribute.php
  20. +13 −0 src/Asserts/FailGenerateSchema.php
  21. +0 −51 src/Concerns/Attributes.php
  22. +0 −25 src/Concerns/ConditionallyLoadsAttributes.php
  23. +0 −26 src/Concerns/Links.php
  24. +0 −40 src/Concerns/Meta.php
  25. +0 −77 src/Concerns/Relationships.php
  26. +0 −44 src/Concerns/Schema.php
  27. +162 −0 src/Descriptors/Describer.php
  28. +9 −0 src/Descriptors/Descriptors.php
  29. +44 −0 src/Descriptors/Relations.php
  30. +153 −0 src/Descriptors/Relations/Relation.php
  31. +21 −0 src/Descriptors/Relations/RelationMany.php
  32. +33 −0 src/Descriptors/Relations/RelationMissing.php
  33. +18 −0 src/Descriptors/Relations/RelationOne.php
  34. +27 −0 src/Descriptors/Relations/RelationRaw.php
  35. +36 −0 src/Descriptors/Resolver.php
  36. +112 −0 src/Descriptors/Values.php
  37. +124 −0 src/Descriptors/Values/Value.php
  38. +23 −0 src/Descriptors/Values/ValueArray.php
  39. +17 −0 src/Descriptors/Values/ValueBool.php
  40. +49 −0 src/Descriptors/Values/ValueDate.php
  41. +22 −0 src/Descriptors/Values/ValueEnum.php
  42. +40 −0 src/Descriptors/Values/ValueFloat.php
  43. +17 −0 src/Descriptors/Values/ValueInteger.php
  44. +17 −0 src/Descriptors/Values/ValueMixed.php
  45. +17 −0 src/Descriptors/Values/ValueString.php
  46. +45 −0 src/Descriptors/Values/ValueStruct.php
  47. +0 −68 src/JsonApiCollection.php
  48. +0 −75 src/JsonApiResource.php
  49. +21 −0 src/Providers/LaravelJsonApiProvider.php
  50. +115 −0 src/Requests/Rules/Fields.php
  51. +89 −0 src/Requests/Rules/Includes.php
  52. +27 −0 src/Requests/Rules/Traits/UseTrans.php
  53. +0 −14 src/Resourceable.php
  54. +90 −0 src/Resources/Concerns/Attributes.php
  55. +121 −0 src/Resources/Concerns/ConditionallyLoadsAttributes.php
  56. +5 −3 src/{ → Resources}/Concerns/Identifier.php
  57. +41 −0 src/Resources/Concerns/Links.php
  58. +70 −0 src/Resources/Concerns/Meta.php
  59. +95 −0 src/Resources/Concerns/PrepareData.php
  60. +6 −6 src/{ → Resources}/Concerns/Relationize.php
  61. +159 −0 src/Resources/Concerns/Relationships.php
  62. +111 −0 src/Resources/Concerns/Schema.php
  63. +24 −0 src/Resources/Concerns/SchemaCollection.php
  64. +2 −2 src/{ → Resources}/Concerns/ToResponse.php
  65. +94 −0 src/Resources/JsonApiCollection.php
  66. +98 −0 src/Resources/JsonApiResource.php
  67. +49 −27 src/{ → Resources}/Relationship.php
  68. +14 −0 src/Resources/Resourceable.php
  69. +25 −0 src/Resources/Skeleton.php
  70. +227 −0 src/Support/Arr.php
  71. +44 −0 src/Support/Config.php
  72. +36 −18 src/Support/FakeModel.php
  73. +76 −6 src/Support/Fields.php
  74. +64 −28 src/Support/Includes.php
  75. +17 −0 src/Support/Supported.php
  76. +29 −0 src/Support/Traits/HasLocalCache.php
  77. +122 −0 src/Support/Values.php
  78. +47 −7 src/Support/With.php
  79. +30 −0 src/Traits/HasRelationLoad.php
  80. +12 −25 tests/Feature/Comment/CollectionTest.php
  81. +57 −5 tests/Feature/FeatureTestCase.php
  82. +34 −27 tests/Feature/SchemaTest.php
  83. +3 −17 tests/Feature/User/CollectionTest.php
  84. +122 −16 tests/Feature/User/ResourceTest.php
  85. +9 −0 tests/Support/Reflect.php
  86. +0 −16 tests/Support/UseLocalApp.php
  87. +5 −4 tests/TestCase.php
  88. +0 −38 tests/Unit/Concerns/ConditionallyLoadsAttributesTest.php
  89. +64 −0 tests/Unit/Descriptors/DescriptorsTraitTest.php
  90. +165 −0 tests/Unit/Descriptors/RelationTest.php
  91. +57 −0 tests/Unit/Descriptors/ResolverTest.php
  92. +289 −0 tests/Unit/Descriptors/ValueTest.php
  93. +37 −0 tests/Unit/Requests/Rules/FieldsTest.php
  94. +38 −0 tests/Unit/Requests/Rules/IncludesTest.php
  95. +35 −11 tests/Unit/{ → Resources}/Concerns/AttributesTest.php
  96. +154 −0 tests/Unit/Resources/Concerns/ConditionallyLoadsAttributesTest.php
  97. +5 −10 tests/Unit/{ → Resources}/Concerns/IdentifierTest.php
  98. +4 −3 tests/Unit/{ → Resources}/Concerns/LinksTest.php
  99. +5 −4 tests/Unit/{ → Resources}/Concerns/MetaTest.php
  100. +42 −7 tests/Unit/{ → Resources}/Concerns/RelationshipsTest.php
  101. +5 −3 tests/Unit/{ → Resources}/JsonApiCollectionTest.php
  102. +109 −4 tests/Unit/{ → Resources}/JsonApiResourceTest.php
  103. +38 −3 tests/Unit/{ → Resources}/RelationshipTest.php
  104. +213 −0 tests/Unit/Support/ArrTest.php
  105. +51 −0 tests/Unit/Support/FakeModelTest.php
  106. +34 −2 tests/Unit/Support/FieldsTest.php
  107. +68 −30 tests/Unit/Support/IncludesTest.php
  108. +152 −0 tests/Unit/Support/ValuesTest.php
  109. +6 −3 tests/Unit/Support/WithTest.php
  110. +9 −0 tests/app/Enums/State.php
  111. +1 −1 tests/app/Factories/CommentFactory.php
  112. +2 −2 tests/app/Factories/PostFactory.php
  113. +2 −2 tests/app/Factories/UserFactory.php
  114. +11 −11 tests/app/Http/Controllers/AsApiController.php
  115. +17 −1 tests/app/Http/Controllers/CommentController.php
  116. +38 −0 tests/app/Http/Controllers/PostController.php
  117. +17 −1 tests/app/Http/Controllers/UserController.php
  118. +27 −0 tests/app/Http/Requests/CommentRequest.php
  119. +27 −0 tests/app/Http/Requests/PostRequest.php
  120. +27 −0 tests/app/Http/Requests/UserRequest.php
  121. +9 −8 tests/app/Http/Resources/CommentResource.php
  122. +14 −9 tests/app/Http/Resources/PostResource.php
  123. +47 −8 tests/app/Http/Resources/UserResource.php
  124. +1 −1 tests/app/Models/Comment.php
  125. +8 −1 tests/app/Models/Post.php
  126. +8 −1 tests/app/Models/User.php
  127. +7 −0 tests/app/jsonapi.php
  128. +18 −0 tests/app/migrations.php
  129. +1 −0 tests/app/routes.php
55 changes: 55 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: build

on:
push:
branches: [ master, '*.*' ]
pull_request:
branches: [ master ]

permissions:
contents: read

jobs:
unit:

runs-on: ubuntu-latest

strategy:
matrix:
php_version: ['8.1', '8.2', '8.3', '8.4']
laravel_version: ['^9.0', '^10.0', '^11.0', '^12.0']
exclude:
- php_version: '8.1'
laravel_version: '^11.0'
- php_version: '8.1'
laravel_version: '^12.0'


steps:
- uses: actions/checkout@v3

- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php_version }}

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php_version }}-laravel-${{ matrix.laravel_version }}
- name: Install dependencies
run: composer require laravel/framework ${{ matrix.laravel_version }} --prefer-dist --no-progress

- name: PHPStan
run: vendor/bin/phpstan analyze

- name: PHPUnit
run: vendor/bin/phpunit --coverage-clover coverage.xml --configuration phpunit.php${{ matrix.php_version }}.xml.dist

- name: Coverage
run: bash <(curl -s https://codecov.io/bash)
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

60 changes: 60 additions & 0 deletions CHANGELOG-1.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Release note
============

# v1.1.9
### Fixes
- `JsonApiResource::toArray` don't filter on `type` and `id`

# v1.1.8
### Add
- `Skeleton::class` present skeleton of a `JsonApiResource::class`

### Changes
- **@deprecated** `Support\With` is replaced by `Support\Arr`
- `Resources\Schema::schema` return `Skeleton`
- `Resources\SchemaCollection::schema` return `Skeleton`

### Fixes
- `JsonApiResource::toArray` return true deep array
- `Support\Includes` when request has empty parameter `include`

# v1.1.7
### Fixes
- Request rules: fix `$failures` not initialized

# v1.1.6
### Fixes
- Request rules: check type of value before assert

# v1.1.5
### Fixes
- `Relationships::mapRelationships` when data is empty

# v1.1.4
### Changes
- phpstan lvl 6 compliant
- Schema safe instantiate self for structure generation
- Relationships allow conditional relation
### Fixes
- Schema correct handle attributes

# v1.1.3
### Added
- `Includes::includes` return the remaining includes for current resource
### Fixes
- FakeModel implement correctly ArrayAccess (add missing return type on offsetGet)

# v1.1.2
### Fixes
- phpstan annotations for rules

# v1.1.1
### Fixes
- rename namespace `Resource` to `Resources`

# v1.1.0
### Added
- implement request validation rules `Requests\Rules\{Includes, Fields}`

### Change
- Improve `Support\Includes::get()`, disable caching.
14 changes: 14 additions & 0 deletions CHANGELOG-1.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Release note
============

# v1.2.1
### Fixes
- Merge values: don't erase concrete values by missing value when merge values

# v1.2.0
### Added
- Implement described notation
- Implement `applyWhen`, Unlike `mergeWhen`, `applyWhen` keeps the keys even when the condition is not met.

### Breaking change
- `Resources\Concerns\Identifier::toType`: by default return type computed from resource class insteadof model class
38 changes: 38 additions & 0 deletions CHANGELOG-1.3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Release note
============

# v1.3.8
### Fixes
- Handle fields input is not an array

# v1.3.7
### Added
- Laravel 10 support

# v1.3.6
### Fixes
- JsonApiResource & Descriptors support any array or object

# v1.3.5
### Fixes
- Descriptors\Values accepts mixed resource

# v1.3.4
### Fixes
- Descriptors\Values accepts mixed resource

# v1.3.3
### Fixes
- PhpStan for Descriptors

# v1.3.2
### Improve
- Autoload improve inclusion

# v1.3.1
### Fixes
- Default value for Relationship::whenIncluded

# v1.3.0
### Added
- Implement autoload relationships
41 changes: 41 additions & 0 deletions CHANGELOG-1.4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Release note
============
# v1.4.6
### Change
- Support PHP 8.4
### Fixed
- Fix `applyWhen` behavior

# v1.4.5
### Change
- `applyWhen` condition can be a closure
- CI: test all supported laravel version

# v1.4.4
### Fixes
- typo on ToResponse : change Content-type to Content-Type

# v1.4.3
### Added
- Add support for Laravel 11
### Breaking changes
- Drop support for Laravel 8

# v1.4.2
### Fixed
- Fix : exception when include relationship one [#19](https://github.com/Ark4ne/laravel-json-api/issues/19)

# v1.4.1
### Fixed
- Fix `autoWhenHas` & `autoWhenIncluded` throw exception.

# v1.4.0
### Added
- Add support for enum in values
- Add auto check when-has attributes
- Add auto set when-included relationships
- Add polyfill for `unless` method
- Surcharge `whenHas` method for support none eloquent models

### Breaking changes
- Drop support for PHP 8.0
5 changes: 5 additions & 0 deletions CHANGELOG-1.5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Release note
============
# v1.5.0
### Added
- Struct value type
Loading