Skip to content

Commit 9eb8afd

Browse files
committed
Merge tag 'v2.0.0' into develop
Laravel 9 and PHP 8.1
2 parents f95b9fc + 9f149a1 commit 9eb8afd

File tree

134 files changed

+244
-163
lines changed

Some content is hidden

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

134 files changed

+244
-163
lines changed

CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
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 (2.x)
6+
## [2.0.0] - 2022-02-09
77

88
### Added
99

@@ -23,6 +23,10 @@ All notable changes to this project will be documented in this file. This projec
2323
- The type-hint of the first constructor argument has changed to `LaravelJsonApi\Core\Support\AppResolver`.
2424
- The deprecated `$container` property has been removed, and the `$app` property is now private. To access the
2525
current application instance in your server class, use `$this->app()` instead.
26+
- **BREAKING** [#110](https://github.com/laravel-json-api/laravel/issues/110) The `model()` and `modelOrFail()` methods
27+
on the `ResourceQuery` request class have been changed from `public` to `protected`. These were not documented for use
28+
on this query class, and were only intended to be used publicly on the `ResourceRequest` class. Although technically
29+
breaking, this change is unlikely to affect the vast majority of applications which should not be using the method.
2630

2731
## [1.1.0] - 2022-01-03
2832

src/Console/Concerns/ResolvesStub.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Console/GeneratorCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Console/MakeAuthorizer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Console/MakeController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Console/MakeFilter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Console/MakeQuery.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Console/MakeRequest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Console/MakeRequests.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Console/MakeResource.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Console/MakeSchema.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Console/MakeServer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Console/MakeSortField.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Console/StubPublish.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Facades/JsonApiRoute.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Http/Controllers/Actions/AttachRelationship.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Http/Controllers/Actions/Destroy.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Http/Controllers/Actions/DetachRelationship.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Http/Controllers/Actions/FetchMany.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Http/Controllers/Actions/FetchOne.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Http/Controllers/Actions/FetchRelated.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Http/Controllers/Actions/FetchRelationship.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Http/Controllers/Actions/Store.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Http/Controllers/Actions/Update.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Http/Controllers/Actions/UpdateRelationship.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Http/Controllers/JsonApiController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Http/Middleware/BootJsonApi.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Http/Requests/AnonymousCollectionQuery.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Http/Requests/AnonymousQuery.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Http/Requests/FormRequest.php

+1-33
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.
@@ -21,13 +21,11 @@
2121

2222
use Illuminate\Auth\AuthenticationException;
2323
use Illuminate\Contracts\Auth\Guard;
24-
use Illuminate\Database\Eloquent\Model;
2524
use Illuminate\Foundation\Http\FormRequest as BaseFormRequest;
2625
use Illuminate\Support\Str;
2726
use LaravelJsonApi\Contracts\Schema\Schema;
2827
use LaravelJsonApi\Core\JsonApiService;
2928
use LaravelJsonApi\Validation\Factory as ValidationFactory;
30-
use LogicException;
3129

3230
class FormRequest extends BaseFormRequest
3331
{
@@ -231,36 +229,6 @@ public function schema(): Schema
231229
return $this->jsonApi()->route()->schema();
232230
}
233231

234-
/**
235-
* Get the model that the request relates to, if the URL has a resource id.
236-
*
237-
* @return Model|object|null
238-
*/
239-
public function model(): ?object
240-
{
241-
$route = $this->jsonApi()->route();
242-
243-
if ($route->hasResourceId()) {
244-
return $route->model();
245-
}
246-
247-
return null;
248-
}
249-
250-
/**
251-
* Get the model that the request relates to, or fail if there is none.
252-
*
253-
* @return Model|object
254-
*/
255-
public function modelOrFail(): object
256-
{
257-
if ($model = $this->model()) {
258-
return $model;
259-
}
260-
261-
throw new LogicException('No model exists for this route.');
262-
}
263-
264232
/**
265233
* @return bool
266234
*/

src/Http/Requests/RequestResolver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.

src/Http/Requests/ResourceQuery.php

+33-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
* Copyright 2021 Cloud Creativity Limited
3+
* Copyright 2022 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.
@@ -20,6 +20,7 @@
2020
namespace LaravelJsonApi\Laravel\Http\Requests;
2121

2222
use Illuminate\Contracts\Validation\Validator;
23+
use Illuminate\Database\Eloquent\Model;
2324
use Illuminate\Http\Response;
2425
use LaravelJsonApi\Contracts\Auth\Authorizer;
2526
use LaravelJsonApi\Contracts\Query\QueryParameters;
@@ -28,6 +29,7 @@
2829
use LaravelJsonApi\Core\Query\FilterParameters;
2930
use LaravelJsonApi\Core\Query\IncludePaths;
3031
use LaravelJsonApi\Core\Query\SortFields;
32+
use LogicException;
3133
use Symfony\Component\HttpKernel\Exception\HttpException;
3234
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
3335
use function array_key_exists;
@@ -237,6 +239,36 @@ public function unrecognisedParameters(): array
237239
])->all();
238240
}
239241

242+
/**
243+
* Get the model that the request relates to, if the URL has a resource id.
244+
*
245+
* @return Model|object|null
246+
*/
247+
protected function model(): ?object
248+
{
249+
$route = $this->jsonApi()->route();
250+
251+
if ($route->hasResourceId()) {
252+
return $route->model();
253+
}
254+
255+
return null;
256+
}
257+
258+
/**
259+
* Get the model that the request relates to, or fail if there is none.
260+
*
261+
* @return Model|object
262+
*/
263+
protected function modelOrFail(): object
264+
{
265+
if ($model = $this->model()) {
266+
return $model;
267+
}
268+
269+
throw new LogicException('No model exists for this route.');
270+
}
271+
240272
/**
241273
* Get the default include paths to use if the client has provided none.
242274
*

0 commit comments

Comments
 (0)