Skip to content

Commit 5d27fb8

Browse files
committed
Merge branch 'release/1.0.0'
2 parents 746565d + d5cbcc6 commit 5d27fb8

Some content is hidden

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

48 files changed

+304
-71
lines changed

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ matrix:
2828
env:
2929
- LARAVEL_VERSION=5.7.*
3030
- PHPUNIT_VERSION=^7.0
31+
- php: 7.2
32+
env:
33+
- LARAVEL_VERSION=5.8.*
34+
- PHPUNIT_VERSION=^7.0
3135
- php: 7.3
3236
env:
3337
- LARAVEL_VERSION=5.5.*
@@ -40,6 +44,10 @@ matrix:
4044
env:
4145
- LARAVEL_VERSION=5.7.*
4246
- PHPUNIT_VERSION=^7.0
47+
- php: 7.3
48+
env:
49+
- LARAVEL_VERSION=5.8.*
50+
- PHPUNIT_VERSION=^7.5
4351

4452
install:
4553
- composer require "laravel/framework:${LARAVEL_VERSION}" --no-update -n

CHANGELOG.md

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

5+
## [1.0.0] - 2019-02-28
6+
7+
### Added
8+
- Package now supports Laravel 5.8.
9+
10+
### Fixed
11+
- [#302](https://github.com/cloudcreativity/laravel-json-api/issues/302)
12+
Reject resource objects sent in relationships, as the spec defines that only resource identifiers
13+
are expected. This is based on the object having either an `attributes` or a `relationships` member.
14+
- [#295](https://github.com/cloudcreativity/laravel-json-api/issues/295)
15+
Use `null` for empty `from`/`to` fields in cursor page meta.
16+
517
## [1.0.0-rc.2] - 2019-02-05
618

719
### Added

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ A demo application is available at [here](https://github.com/cloudcreativity/dem
6060

6161
| Laravel | This Package | EOL? |
6262
| --- | --- | --- |
63-
| 5.7.* | `1.0.0-rc.2` | - |
64-
| 5.6.* | `1.0.0-rc.2` | - |
65-
| 5.5.* | `1.0.0-rc.2` | - |
63+
| 5.8.* | `^1.0` | - |
64+
| 5.7.* | `^1.0` | - |
65+
| 5.6.* | `^1.0` | - |
66+
| 5.5.* | `^1.0` | - |
6667
| 5.4.* | `1.0.0-beta.3` | EOL |
6768

6869
Make sure you consult the [Upgrade Guide](http://laravel-json-api.readthedocs.io/en/latest/upgrade/)

composer.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,24 @@
2525
"php": "^7.1",
2626
"ext-json": "*",
2727
"cloudcreativity/utils-object": "^1.0",
28-
"illuminate/console": "5.5.*|5.6.*|5.7.*",
29-
"illuminate/contracts": "5.5.*|5.6.*|5.7.*",
30-
"illuminate/database": "5.5.*|5.6.*|5.7.*",
31-
"illuminate/filesystem": "5.5.*|5.6.*|5.7.*",
32-
"illuminate/http": "5.5.*|5.6.*|5.7.*",
33-
"illuminate/pagination": "5.5.*|5.6.*|5.7.*",
34-
"illuminate/support": "5.5.*|5.6.*|5.7.*",
28+
"illuminate/console": "5.5.*|5.6.*|5.7.*|5.8.*",
29+
"illuminate/contracts": "5.5.*|5.6.*|5.7.*|5.8.*",
30+
"illuminate/database": "5.5.*|5.6.*|5.7.*|5.8.*",
31+
"illuminate/filesystem": "5.5.*|5.6.*|5.7.*|5.8.*",
32+
"illuminate/http": "5.5.*|5.6.*|5.7.*|5.8.*",
33+
"illuminate/pagination": "5.5.*|5.6.*|5.7.*|5.8.*",
34+
"illuminate/support": "5.5.*|5.6.*|5.7.*|5.8.*",
3535
"neomerx/json-api": "^1.0.3",
3636
"ramsey/uuid": "^3.0",
3737
"symfony/psr-http-message-bridge": "^1.0",
3838
"zendframework/zend-diactoros": "^1.3"
3939
},
4040
"require-dev": {
4141
"ext-sqlite3": "*",
42-
"cloudcreativity/json-api-testing": "1.0.0-rc.1",
42+
"cloudcreativity/json-api-testing": "^1.0.0",
4343
"guzzlehttp/guzzle": "^6.3",
4444
"mockery/mockery": "^1.1",
45-
"orchestra/testbench": "3.5.*|3.6.*|3.7.*",
45+
"orchestra/testbench": "3.5.*|3.6.*|3.7.*|3.8.*",
4646
"phpunit/phpunit": "^6.0|^7.0"
4747
},
4848
"suggest": {

docs/installation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
Install using [Composer](http://getcomposer.org):
44

55
``` bash
6-
$ composer require cloudcreativity/laravel-json-api:1.0.0-rc.2
7-
$ composer require --dev cloudcreativity/json-api-testing:1.0.0-rc.1
6+
$ composer require cloudcreativity/laravel-json-api
7+
$ composer require --dev cloudcreativity/json-api-testing
88
```
99

1010
This package's service provider and facade will be automatically added using package discovery. You will

docs/upgrade.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Upgrade Guide
22

3-
## 1.0.0-rc.1 to 1.0.0-rc.2
3+
## 1.0.0-rc.* to ^1.0
44

55
No changes are required to upgrade.
66

resources/lang/en/errors.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@
4646
'code' => '',
4747
],
4848

49+
'member_identifier_expected' => [
50+
'title' => 'Non-Compliant JSON API Document',
51+
'detail' => 'The member :member must be a resource identifier.',
52+
'code' => '',
53+
],
54+
4955
'member_string_expected' => [
5056
'title' => 'Non-Compliant JSON API Document',
5157
'detail' => "The member :member must be a string.",

src/Codec/Decoding.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use CloudCreativity\LaravelJsonApi\Contracts\Decoder\DecoderInterface;
2121
use CloudCreativity\LaravelJsonApi\Decoder\JsonApiDecoder;
2222
use CloudCreativity\LaravelJsonApi\Exceptions\RuntimeException;
23-
use Illuminate\Support\Collection;
2423
use Neomerx\JsonApi\Contracts\Http\Headers\MediaTypeInterface;
2524
use Neomerx\JsonApi\Http\Headers\MediaType;
2625

src/Pagination/CursorPaginator.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,26 @@ public function getPerPage()
123123
return $this->cursor->getLimit();
124124
}
125125

126+
/**
127+
* @return string|null
128+
*/
129+
public function getFrom(): ?string
130+
{
131+
$first = $this->firstItem();
132+
133+
return $first ? (string) $first : null;
134+
}
135+
136+
/**
137+
* @return string|null
138+
*/
139+
public function getTo(): ?string
140+
{
141+
$last = $this->lastItem();
142+
143+
return $last ? (string) $last : null;
144+
}
145+
126146
/**
127147
* @inheritDoc
128148
*/
@@ -139,4 +159,20 @@ public function count()
139159
return $this->items->count();
140160
}
141161

162+
/**
163+
* @return bool
164+
*/
165+
public function isEmpty(): bool
166+
{
167+
return $this->items->isEmpty();
168+
}
169+
170+
/**
171+
* @return bool
172+
*/
173+
public function isNotEmpty(): bool
174+
{
175+
return !$this->isEmpty();
176+
}
177+
142178
}

src/Pagination/CursorStrategy.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ protected function createFirstLink(CursorPaginator $paginator, array $parameters
263263
/**
264264
* @param CursorPaginator $paginator
265265
* @param array $parameters
266-
* @return LinkInterface
266+
* @return LinkInterface|null
267267
*/
268268
protected function createNextLink(CursorPaginator $paginator, array $parameters = [])
269269
{
@@ -280,10 +280,14 @@ protected function createNextLink(CursorPaginator $paginator, array $parameters
280280
/**
281281
* @param CursorPaginator $paginator
282282
* @param array $parameters
283-
* @return LinkInterface
283+
* @return LinkInterface|null
284284
*/
285285
protected function createPrevLink(CursorPaginator $paginator, array $parameters = [])
286286
{
287+
if ($paginator->isEmpty()) {
288+
return null;
289+
}
290+
287291
return $this->createLink([
288292
$this->before => $paginator->firstItem(),
289293
$this->limit => $paginator->getPerPage(),
@@ -325,8 +329,8 @@ protected function createMeta(CursorPaginator $paginator)
325329
{
326330
$meta = [
327331
'per-page' => $paginator->getPerPage(),
328-
'from' => (string) $paginator->firstItem(),
329-
'to' => (string) $paginator->lastItem(),
332+
'from' => $paginator->getFrom(),
333+
'to' => $paginator->getTo(),
330334
'has-more' => $paginator->hasMore(),
331335
];
332336

0 commit comments

Comments
 (0)