Skip to content

Commit 5b4fb29

Browse files
committed
Merge branch 'release/6.1.0'
2 parents c8cc395 + 6fc2e01 commit 5b4fb29

File tree

422 files changed

+629
-537
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

422 files changed

+629
-537
lines changed

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ jobs:
1414
strategy:
1515
fail-fast: true
1616
matrix:
17-
php: [8.1, 8.2]
17+
php: [8.1, 8.2, 8.3]
1818
laravel: [10]
1919

2020
steps:
2121
- name: Checkout Code
22-
uses: actions/checkout@v3
22+
uses: actions/checkout@v4
2323

2424
- name: Setup PHP
2525
uses: shivammathur/setup-php@v2
@@ -34,7 +34,7 @@ jobs:
3434
run: composer require "laravel/framework:^${{ matrix.laravel }}" --no-update
3535

3636
- name: Install dependencies
37-
uses: nick-fields/retry@v2
37+
uses: nick-fields/retry@v3
3838
with:
3939
timeout_minutes: 5
4040
max_attempts: 5

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
vendor/
22
composer.lock
3-
.phpunit.result.cache
3+
.phpunit.cache/

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@
33
All notable changes to this project will be documented in this file. This project adheres to
44
[Semantic Versioning](http://semver.org/) and [this changelog format](http://keepachangelog.com/).
55

6+
## Unreleased
7+
8+
## [6.1.0] - 2024-02-11
9+
10+
### Fixed
11+
12+
- [#642](https://github.com/cloudcreativity/laravel-json-api/pull/642) Add missing resource meta functionality.
13+
- [#643](https://github.com/cloudcreativity/laravel-json-api/issues/643) Add missing resource link functionality.
14+
615
## [6.0.0] - 2023-02-14
716

817
### Changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"laravel/ui": "^4.2",
3939
"mockery/mockery": "^1.1",
4040
"orchestra/testbench": "^8.0",
41-
"phpunit/phpunit": "^9.5.28"
41+
"phpunit/phpunit": "^10.5"
4242
},
4343
"suggest": {
4444
"cloudcreativity/json-api-testing": "Required to use the test helpers."

database/migrations/2018_10_23_000001_create_client_jobs_table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

docs/basics/schemas.md

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -384,20 +384,35 @@ By default all resource objects will be encoded with their `self` link, e.g.:
384384
}
385385
```
386386

387-
You can change this behaviour by overloading the `getResourceLinks` or `getIncludedResourceLinks` methods.
388-
For example:
387+
You can change this behaviour by implementing the `getResourceLinks` method. For example, if you do not want any links
388+
to be serialized:
389389

390390
```php
391391
class Schema extends SchemaProvider
392392
{
393393
// ...
394394

395-
public function getResourceLinks($resource)
395+
public function getResourceLinks($resource): ?array
396396
{
397-
$links = parent::getResourceLinks($resource);
398-
$links['foo'] = $this->createLink('posts/foo');
397+
return null;
398+
}
399+
}
400+
```
401+
402+
If you return an array without any `self` key in it, the `self` link will be automatically added. If you do not want
403+
the `self` link to be set, set the array key `self` to `false`.
404+
405+
```php
406+
class Schema extends SchemaProvider
407+
{
408+
// ...
399409

400-
return $links;
410+
public function getResourceLinks($resource): array
411+
{
412+
return [
413+
// "self" will automatically be added as it is not set to false.
414+
'foo' => $this->createLink('posts/foo'),
415+
];
401416
}
402417

403418
}
@@ -423,33 +438,23 @@ This would result in the following resource object:
423438
> The `createLink` method allows you to pass in link meta and set whether the URI is relative to the API or an
424439
absolute path.
425440

426-
If you want to only change the links when the resource is appearing in the `included` section of the JSON API
427-
document, overload the `getIncludedResourceLinks()` method instead.
428-
429441
## Meta
430442

431-
You can add top-level `meta` to your resource object using the `getPrimaryMeta()` or `getInclusionMeta()` methods
432-
on your schema. These are called depending on whether your resource is appearing in either the primary `data`
433-
member of the JSON API document or the `included` member.
443+
You can add top-level `meta` to your resource object using the `getResourceMeta()` method
444+
on your schema.
434445

435-
For example, the following would add meta to your resource object regardless of whether it is primary data or
436-
included in the document:
446+
For example:
437447

438448
```php
439449
class Schema extends SchemaProvider
440450
{
441451
// ...
442452

443-
public function getPrimaryMeta($resource)
453+
public function getResourceMeta($resource)
444454
{
445455
return ['foo' => 'bar'];
446456
}
447457

448-
public function getInclusionMeta($resource)
449-
{
450-
return $this->getPrimaryMeta($resource);
451-
}
452-
453458
}
454459
```
455460

docs/upgrade.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,28 @@ public function getId(object $resource): string
103103
return (string) $resource->getRouteKey();
104104
}
105105
```
106+
The functions that are used to call meta data has also been changed. Before there were these 2 functions:
107+
108+
```php
109+
public function getPrimaryMeta($resource)
110+
{
111+
return ['foo => 'bar'];
112+
}
113+
public function getInclusionMeta($resource)
114+
{
115+
return $this->getPrimaryMeta($resource);
116+
}
117+
```
118+
119+
These have now been replaced with 1 function:
120+
121+
```php
122+
public function getResourceMeta($resource): ?array
123+
{
124+
return ['foo => 'bar'];
125+
}
126+
```
127+
This method will be used in place of the other 2. In the rare event that your inclution meta was different from primary, you may need to amalgemate.
106128

107129
### Errors
108130

@@ -116,4 +138,4 @@ your use against the new constructor arguments by inspecting the class directly.
116138

117139
## 2.x to 3.0
118140

119-
[Use this link to view the 3.0 upgrade guide.](https://github.com/cloudcreativity/laravel-json-api/blob/v3.3.0/docs/upgrade.md)
141+
[Use this link to view the 3.0 upgrade guide.](https://github.com/cloudcreativity/laravel-json-api/blob/v3.3.0/docs/upgrade.md)

helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2023 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

lang/en/errors.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2022 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

lang/en/validation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2022 Cloud Creativity Limited
3+
* Copyright 2024 Cloud Creativity Limited
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy