Skip to content

Commit f84fa0a

Browse files
committed
Merge branch 'release/4.3.1'
2 parents 37c4734 + 84da08d commit f84fa0a

File tree

4 files changed

+46
-42
lines changed

4 files changed

+46
-42
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. This projec
55

66
## Unreleased
77

8+
## [4.3.1] - 2024-11-29
9+
10+
### Fixed
11+
12+
- Reverted [#19](https://github.com/laravel-json-api/core/pull/19) as the changes were breaking, so should not have been
13+
released as a minor version.
14+
815
## [4.3.0] - 2024-11-26
916

1017
### Added

composer.json

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"require": {
2626
"php": "^8.2",
2727
"ext-json": "*",
28-
"illuminate/auth": "^11.33",
2928
"illuminate/contracts": "^11.0",
3029
"illuminate/http": "^11.0",
3130
"illuminate/support": "^11.0"

src/Contracts/Auth/Authorizer.php

+20-21
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace LaravelJsonApi\Contracts\Auth;
1313

14-
use Illuminate\Auth\Access\Response;
1514
use Illuminate\Http\Request;
1615

1716
interface Authorizer
@@ -21,93 +20,93 @@ interface Authorizer
2120
*
2221
* @param Request $request
2322
* @param string $modelClass
24-
* @return bool|Response
23+
* @return bool
2524
*/
26-
public function index(Request $request, string $modelClass): bool|Response;
25+
public function index(Request $request, string $modelClass): bool;
2726

2827
/**
2928
* Authorize the store controller action.
3029
*
3130
* @param Request $request
3231
* @param string $modelClass
33-
* @return bool|Response
32+
* @return bool
3433
*/
35-
public function store(Request $request, string $modelClass): bool|Response;
34+
public function store(Request $request, string $modelClass): bool;
3635

3736
/**
3837
* Authorize the show controller action.
3938
*
4039
* @param Request $request
4140
* @param object $model
42-
* @return bool|Response
41+
* @return bool
4342
*/
44-
public function show(Request $request, object $model): bool|Response;
43+
public function show(Request $request, object $model): bool;
4544

4645
/**
4746
* Authorize the update controller action.
4847
*
4948
* @param object $model
5049
* @param Request $request
51-
* @return bool|Response
50+
* @return bool
5251
*/
53-
public function update(Request $request, object $model): bool|Response;
52+
public function update(Request $request, object $model): bool;
5453

5554
/**
5655
* Authorize the destroy controller action.
5756
*
5857
* @param Request $request
5958
* @param object $model
60-
* @return bool|Response
59+
* @return bool
6160
*/
62-
public function destroy(Request $request, object $model): bool|Response;
61+
public function destroy(Request $request, object $model): bool;
6362

6463
/**
6564
* Authorize the show-related controller action.
6665
*
6766
* @param Request $request
6867
* @param object $model
6968
* @param string $fieldName
70-
* @return bool|Response
69+
* @return bool
7170
*/
72-
public function showRelated(Request $request, object $model, string $fieldName): bool|Response;
71+
public function showRelated(Request $request, object $model, string $fieldName): bool;
7372

7473
/**
7574
* Authorize the show-relationship controller action.
7675
*
7776
* @param Request $request
7877
* @param object $model
7978
* @param string $fieldName
80-
* @return bool|Response
79+
* @return bool
8180
*/
82-
public function showRelationship(Request $request, object $model, string $fieldName): bool|Response;
81+
public function showRelationship(Request $request, object $model, string $fieldName): bool;
8382

8483
/**
8584
* Authorize the update-relationship controller action.
8685
*
8786
* @param Request $request
8887
* @param object $model
8988
* @param string $fieldName
90-
* @return bool|Response
89+
* @return bool
9190
*/
92-
public function updateRelationship(Request $request, object $model, string $fieldName): bool|Response;
91+
public function updateRelationship(Request $request, object $model, string $fieldName): bool;
9392

9493
/**
9594
* Authorize the attach-relationship controller action.
9695
*
9796
* @param Request $request
9897
* @param object $model
9998
* @param string $fieldName
100-
* @return bool|Response
99+
* @return bool
101100
*/
102-
public function attachRelationship(Request $request, object $model, string $fieldName): bool|Response;
101+
public function attachRelationship(Request $request, object $model, string $fieldName): bool;
103102

104103
/**
105104
* Authorize the detach-relationship controller action.
106105
*
107106
* @param Request $request
108107
* @param object $model
109108
* @param string $fieldName
110-
* @return bool|Response
109+
* @return bool
111110
*/
112-
public function detachRelationship(Request $request, object $model, string $fieldName): bool|Response;
111+
public function detachRelationship(Request $request, object $model, string $fieldName): bool;
113112
}

src/Core/Auth/Authorizer.php

+19-20
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace LaravelJsonApi\Core\Auth;
1313

1414
use Illuminate\Contracts\Auth\Access\Gate;
15-
use Illuminate\Auth\Access\Response;
1615
use Illuminate\Http\Request;
1716
use LaravelJsonApi\Contracts\Auth\Authorizer as AuthorizerContract;
1817
use LaravelJsonApi\Contracts\Schema\Schema;
@@ -48,10 +47,10 @@ public function __construct(Gate $gate, JsonApiService $service)
4847
/**
4948
* @inheritDoc
5049
*/
51-
public function index(Request $request, string $modelClass): bool|Response
50+
public function index(Request $request, string $modelClass): bool
5251
{
5352
if ($this->mustAuthorize()) {
54-
return $this->gate->inspect(
53+
return $this->gate->check(
5554
'viewAny',
5655
$modelClass
5756
);
@@ -63,10 +62,10 @@ public function index(Request $request, string $modelClass): bool|Response
6362
/**
6463
* @inheritDoc
6564
*/
66-
public function store(Request $request, string $modelClass): bool|Response
65+
public function store(Request $request, string $modelClass): bool
6766
{
6867
if ($this->mustAuthorize()) {
69-
return $this->gate->inspect(
68+
return $this->gate->check(
7069
'create',
7170
$modelClass
7271
);
@@ -78,10 +77,10 @@ public function store(Request $request, string $modelClass): bool|Response
7877
/**
7978
* @inheritDoc
8079
*/
81-
public function show(Request $request, object $model): bool|Response
80+
public function show(Request $request, object $model): bool
8281
{
8382
if ($this->mustAuthorize()) {
84-
return $this->gate->inspect(
83+
return $this->gate->check(
8584
'view',
8685
$model
8786
);
@@ -93,10 +92,10 @@ public function show(Request $request, object $model): bool|Response
9392
/**
9493
* @inheritDoc
9594
*/
96-
public function update(Request $request, object $model): bool|Response
95+
public function update(Request $request, object $model): bool
9796
{
9897
if ($this->mustAuthorize()) {
99-
return $this->gate->inspect(
98+
return $this->gate->check(
10099
'update',
101100
$model
102101
);
@@ -108,10 +107,10 @@ public function update(Request $request, object $model): bool|Response
108107
/**
109108
* @inheritDoc
110109
*/
111-
public function destroy(Request $request, object $model): bool|Response
110+
public function destroy(Request $request, object $model): bool
112111
{
113112
if ($this->mustAuthorize()) {
114-
return $this->gate->inspect(
113+
return $this->gate->check(
115114
'delete',
116115
$model
117116
);
@@ -123,10 +122,10 @@ public function destroy(Request $request, object $model): bool|Response
123122
/**
124123
* @inheritDoc
125124
*/
126-
public function showRelated(Request $request, object $model, string $fieldName): bool|Response
125+
public function showRelated(Request $request, object $model, string $fieldName): bool
127126
{
128127
if ($this->mustAuthorize()) {
129-
return $this->gate->inspect(
128+
return $this->gate->check(
130129
'view' . Str::classify($fieldName),
131130
$model
132131
);
@@ -138,18 +137,18 @@ public function showRelated(Request $request, object $model, string $fieldName):
138137
/**
139138
* @inheritDoc
140139
*/
141-
public function showRelationship(Request $request, object $model, string $fieldName): bool|Response
140+
public function showRelationship(Request $request, object $model, string $fieldName): bool
142141
{
143142
return $this->showRelated($request, $model, $fieldName);
144143
}
145144

146145
/**
147146
* @inheritDoc
148147
*/
149-
public function updateRelationship(Request $request, object $model, string $fieldName): bool|Response
148+
public function updateRelationship(Request $request, object $model, string $fieldName): bool
150149
{
151150
if ($this->mustAuthorize()) {
152-
return $this->gate->inspect(
151+
return $this->gate->check(
153152
'update' . Str::classify($fieldName),
154153
[$model, $this->createRelation($request, $fieldName)]
155154
);
@@ -161,10 +160,10 @@ public function updateRelationship(Request $request, object $model, string $fiel
161160
/**
162161
* @inheritDoc
163162
*/
164-
public function attachRelationship(Request $request, object $model, string $fieldName): bool|Response
163+
public function attachRelationship(Request $request, object $model, string $fieldName): bool
165164
{
166165
if ($this->mustAuthorize()) {
167-
return $this->gate->inspect(
166+
return $this->gate->check(
168167
'attach' . Str::classify($fieldName),
169168
[$model, $this->createRelation($request, $fieldName)]
170169
);
@@ -176,10 +175,10 @@ public function attachRelationship(Request $request, object $model, string $fiel
176175
/**
177176
* @inheritDoc
178177
*/
179-
public function detachRelationship(Request $request, object $model, string $fieldName): bool|Response
178+
public function detachRelationship(Request $request, object $model, string $fieldName): bool
180179
{
181180
if ($this->mustAuthorize()) {
182-
return $this->gate->inspect(
181+
return $this->gate->check(
183182
'detach' . Str::classify($fieldName),
184183
[$model, $this->createRelation($request, $fieldName)]
185184
);

0 commit comments

Comments
 (0)