8000 Merge branch 'release/1.3.0' · khomsovon/laravel-json-api@c0c1a45 · GitHub
[go: up one dir, main page]

Skip to content

Commit c0c1a45

Browse files
committed
Merge branch 'release/1.3.0'
2 parents ef5786d + 03bab73 commit c0c1a45

37 files changed

+1071
-160
lines changed

.travis.yml

Lines changed: 39 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,47 @@ sudo: false
44

55
matrix:
66
include:
7-
- php: 7.1
8-
env:
9-
- LARAVEL_VERSION=5.5.*
10-
- PHPUNIT_VERSION=^6.5
11-
- php: 7.1
12-
env:
13-
- LARAVEL_VERSION=5.6.*
14-
- PHPUNIT_VERSION=^7.0
15-
- php: 7.1
16-
env:
17-
- LARAVEL_VERSION=5.7.*
18-
- PHPUNIT_VERSION=^7.0
19-
- php: 7.2
20-
env:
21-
- LARAVEL_VERSION=5.5.*
22-
- PHPUNIT_VERSION=^6.5
23-
- php: 7.2
24-
env:
25-
- LARAVEL_VERSION=5.6.*
26-
- PHPUNIT_VERSION=^7.0
27-
- php: 7.2
28-
env:
29-
- LARAVEL_VERSION=5.7.*
30-
- PHPUNIT_VERSION=^7.0
31-
- php: 7.2
32-
env:
33-
- LARAVEL_VERSION=5.8.*
34-
- PHPUNIT_VERSION=^7.0
35-
- php: 7.3
36-
env:
37-
- LARAVEL_VERSION=5.5.*
38-
- PHPUNIT_VERSION=^6.5
39-
- php: 7.3
40-
env:
41-
- LARAVEL_VERSION=5.6.*
42-
- PHPUNIT_VERSION=^7.0
43-
- php: 7.3
44-
env:
45-
- LARAVEL_VERSION=5.7.*
46-
- PHPUNIT_VERSION=^7.0
47-
- php: 7.3
48-
env:
49-
- LARAVEL_VERSION=5.8.*
50-
- PHPUNIT_VERSION=^7.5
7+
- php: 7.1
8+
env:
9+
- LARAVEL_VERSION=5.5.*
10+
- PHPUNIT_VERSION=^6.5
11+
- php: 7.1
12+
env:
13+
- LARAVEL_VERSION=5.6.*
14+
- PHPUNIT_VERSION=^7.0
15+
- php: 7.1
16+
env:
17+
- LARAVEL_VERSION=5.7.*
18+
- PHPUNIT_VERSION=^7.0
19+
- php: 7.2
20+
env:
21+
- LARAVEL_VERSION=5.5.*
22+
- PHPUNIT_VERSION=^6.5
23+
- php: 7.2
24+
env:
25+
- LARAVEL_VERSION=5.8.*
26+
- PHPUNIT_VERSION=^7.0
27+
- php: 7.2
28+
env:
29+
- LARAVEL_VERSION=5.9.*
30+
- PHPUNIT_VERSION=^7.0
31+
- php: 7.3
32+
env:
33+
- LARAVEL_VERSION=5.5.*
34+
- PHPUNIT_VERSION=^6.5
35+
- php: 7.3
36+
env:
37+
- LARAVEL_VERSION=5.8.*
38+
- PHPUNIT_VERSION=^7.0
39+
- php: 7.3
40+
env:
41+
- LARAVEL_VERSION=5.9.*
42+
- PHPUNIT_VERSION=^7.5
5143

5244
install:
53-
- composer require "laravel/framework:${LARAVEL_VERSION}" --no-update -n
54-
- composer require "phpunit/phpunit:${PHPUNIT_VERSION}" --dev --no-update -n
55-
- travis_retry composer install --no-suggest --prefer-dist -n -o
45+
- composer require "laravel/framework:${LARAVEL_VERSION}" --no-update -n
46+
- composer require "phpunit/phpunit:${PHPUNIT_VERSION}" --dev --no-update -n
47+
- travis_retry composer install --no-suggest --prefer-dist -n -o
5648

5749
script:
5850
- vendor/bin/phpunit

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,34 @@
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.3.0] - 2019-07-24
6+
7+
Package now supports Laravel 5.9.
8+
9+
### Added
10+
- [#352](https://github.com/cloudcreativity/laravel-json-api/issues/352)
11+
Can now set an API's default controller name to the singular version of the resource type.
12+
- Can now register a callback for resolving a controller name from a resource type.
13+
- [#373](https://github.com/cloudcreativity/laravel-json-api/issues/373)
14+
Can now change the JSON API controller's default connection and whether it uses transactions
15+
via an API's config.
16+
- [#377](https://github.com/cloudcreativity/laravel-json-api/issues/377)
17+
Can now toggle the simple pagination strategy back to using length aware pagination.
18+
- [#380](https://github.com/cloudcreativity/laravel-json-api/issues/380)
19+
Can now customise the conversion of a resource id to a database id on an adapter by overloading the
20+
`databaseId()` method.
21+
- New `HasOne` and `HasMany` rule objects for validating that a relationship is *to-one* or
22+
*to-many*, and has the expected resource type(s).
23+
- [#391](https://github.com/cloudcreativity/laravel-json-api/issues/391)
24+
Allow the validators `existingRelationships()` method to return the existing related records,
25+
and automatically convert these to JSON API identifiers.
26+
27+
### Fixed
28+
- [#371](https://github.com/cloudcreativity/laravel-json-api/issues/371)
29+
Ensure Eloquent delete/deleting events are fired when soft-deleting a resource.
30+
- Eloquent adapter hooks will now be invoked when force-deleting a resource that uses
31+
the `SoftDeletesModels` trait.
32+
533
## [1.2.0] - 2019-06-20
634

735
### Added

README.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,7 @@ The following additional features are also supported:
3333
- Support multiple media-types within your API.
3434
- Generators for all the classes you need to add a resource to your API.
3535

36-
Installation instructions and documentation are available on
37-
[Read the Docs](http://laravel-json-api.readthedocs.io/en/latest/).
38-
39-
> Credit where credit is due: this package is based on the framework agnostic package
40-
[neomerx/json-api](https://github.com/neomerx/json-api).
41-
42-
## What is JSON API?
36+
### What is JSON API?
4337

4438
From [jsonapi.org](http://jsonapi.org)
4539

@@ -52,6 +46,14 @@ efficiently caching responses, sometimes eliminating network requests entirely.
5246

5347
For full information on the spec, plus examples, see [http://jsonapi.org](http://jsonapi.org).
5448

49+
## Tutorial and Documentation
50+
51+
Want a tutorial to get started? Read the
52+
[*How to JSON:API* Laravel tutorial.](https://howtojsonapi.com/laravel.html)
53+
54+
Full package documentation is available on
55+
[Read the Docs](http://laravel-json-api.readthedocs.io/en/latest/).
56+
5557
## Demo
5658

5759
A demo application is available at [here](https://github.com/cloudcreativity/demo-laravel-json-api).
@@ -60,6 +62,7 @@ A demo application is available at [here](https://github.com/cloudcreativity/dem
6062

6163
| Laravel | This Package | EOL? |
6264
| --- | --- | --- |
65+
| 5.9.* | `^1.3` | - |
6366
| 5.8.* | `^1.0` | - |
6467
| 5.7.* | `^1.0` | - |
6568
| 5.6.* | `^1.0` | - |
@@ -75,10 +78,6 @@ Currently we have not integrated the package with Lumen. We do not have any acti
7578
so if you do and can help, please let us know on
7679
[this issue](https://github.com/cloudcreativity/laravel-json-api/issues/61).
7780

78-
## Documentation
79-
80-
Documentation is available on [Read the Docs](http://laravel-json-api.readthedocs.io/en/latest/).
81-
8281
## License
8382

8483
Apache License (Version 2.0). Please see [License File](LICENSE) for more information.

composer.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,25 @@
2525
"php": "^7.1",
2626
"ext-json": "*",
2727
"cloudcreativity/utils-object": "^1.0",
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.*",
28+
"illuminate/console": "5.5.*|5.6.*|5.7.*|5.8.*|5.9.*",
29+
"illuminate/contracts": "5.5.*|5.6.*|5.7.*|5.8.*|5.9.*",
30+
"illuminate/database": "5.5.*|5.6.*|5.7.*|5.8.*|5.9.*",
31+
"illuminate/filesystem": "5.5.*|5.6.*|5.7.*|5.8.*|5.9.*",
32+
"illuminate/http": "5.5.*|5.6.*|5.7.*|5.8.*|5.9.*",
33+
"illuminate/pagination": "5.5.*|5.6.*|5.7.*|5.8.*|5.9.*",
34+
"illuminate/support": "5.5.*|5.6.*|5.7.*|5.8.*|5.9.*",
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.0|^2.0"
3939
},
4040
"require-dev": {
4141
"ext-sqlite3": "*",
42-
"cloudcreativity/json-api-testing": "^1.0.0",
42+
"cloudcreativity/json-api-testing": "^1.1",
43+
"composer/semver": "^1.5",
4344
"guzzlehttp/guzzle": "^6.3",
4445
"mockery/mockery": "^1.1",
45-
"orchestra/testbench": "3.5.*|3.6.*|3.7.*|3.8.*",
46+
"orchestra/testbench": "3.5.*|3.6.*|3.7.*|3.8.*|3.9.*",
4647
"phpunit/phpunit": "^6.0|^7.0"
4748
},
4849
"suggest": {
@@ -77,7 +78,7 @@
7778
}
7879
}
7980
},
80-
"minimum-stability": "stable",
81+
"minimum-stability": "dev",
8182
"prefer-stable": true,
8283
"config": {
8384
"sort-packages": true

docs/basics/routing.md

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,25 +240,51 @@ JsonApi::register('default')->routes(function ($api) {
240240
## Controllers
241241

242242
By default no controller is required because this package contains a standard controller for processing JSON API
243-
requests. However it is possible to specify your own controller, using the `controller` option.
243+
requests. However it is possible to specify that a resource has its own controller, using the `controller` method.
244244

245245
For example, the following would use the `PostsController` in the `Api` namespace:
246246

247247
```php
248248
JsonApi::register('default')->withNamespace('Api')->routes(function ($api, $router) {
249-
$api->resource('posts')->controller();
249+
$api->resource('posts')->controller(); // uses PostsController
250250
});
251251
```
252252

253+
### Controller Names
254+
253255
If you call `controller()` without any arguments, we assume your controller is the camel case name version of
254256
the resource type with `Controller` on the end. I.e. `posts` would expect `PostsController` and
255-
`blog-posts` would expect `BlogPostsController`.
257+
`blog-posts` would expect `BlogPostsController`. Or if your resource type was `post`,
258+
we would guess `PostController`.
256259

257-
If your controller does not conform to this expectation, supply the controller name as follows:
260+
If your resource names are plural, e.g. `posts`, but you would like to use the singular for the controller
261+
name, i.e. `PostController`, use the `singularControllers()` method as follows:
262+
263+
```php
264+
JsonApi::register('default')
265+
->withNamespace('Api')
266+
->singularControllers()
267+
->routes(function ($api, $router) {
268+
$api->resource('posts')->controller(); // uses PostController
269+
});
270+
```
271+
272+
If your controller names do not conform to either of these patterns, you have two options. Either explicitly
273+
provide the controller name for each resource, e.g.:
258274

259275
```php
260276
JsonApi::register('default')->withNamespace('Api')->routes(function ($api, $router) {
261-
$api->resource('posts')->controller('PostController');
277+
$api->resource('posts')->controller('PostResourceController');
278+
});
279+
```
280+
281+
Or you can provide a callback to work it out from the resource name:
282+
283+
```php
284+
JsonApi::register('default')->withNamespace('Api')->controllerResolver(function ($resourceType) {
285+
return ucfirst($resourceType) . 'ResourceController';
286+
})->routes(function ($api, $router) {
287+
$api->resource('posts')->controller(); // expects PostsResourceController
262288
});
263289
```
264290

@@ -275,7 +301,7 @@ JsonApi::register('default')
275301
->withNamespace('Api')
276302
->defaultController('DefaultController')
277303
->routes(function ($api, $router) {
278-
$api->resource('posts')->controller();
304+
$api->resource('posts'); // uses DefaultController instead of our JsonApiController
279305
});
280306
```
281307

0 commit comments

Comments
 (0)
0