12
12
namespace LaravelJsonApi \Core \Auth ;
13
13
14
14
use Illuminate \Contracts \Auth \Access \Gate ;
15
- use Illuminate \Auth \Access \Response ;
16
15
use Illuminate \Http \Request ;
17
16
use LaravelJsonApi \Contracts \Auth \Authorizer as AuthorizerContract ;
18
17
use LaravelJsonApi \Contracts \Schema \Schema ;
@@ -48,10 +47,10 @@ public function __construct(Gate $gate, JsonApiService $service)
48
47
/**
49
48
* @inheritDoc
50
49
*/
51
- public function index (Request $ request , string $ modelClass ): bool | Response
50
+ public function index (Request $ request , string $ modelClass ): bool
52
51
{
53
52
if ($ this ->mustAuthorize ()) {
54
- return $ this ->gate ->inspect (
53
+ return $ this ->gate ->check (
55
54
'viewAny ' ,
56
55
$ modelClass
57
56
);
@@ -63,10 +62,10 @@ public function index(Request $request, string $modelClass): bool|Response
63
62
/**
64
63
* @inheritDoc
65
64
*/
66
- public function store (Request $ request , string $ modelClass ): bool | Response
65
+ public function store (Request $ request , string $ modelClass ): bool
67
66
{
68
67
if ($ this ->mustAuthorize ()) {
69
- return $ this ->gate ->inspect (
68
+ return $ this ->gate ->check (
70
69
'create ' ,
71
70
$ modelClass
72
71
);
@@ -78,10 +77,10 @@ public function store(Request $request, string $modelClass): bool|Response
78
77
/**
79
78
* @inheritDoc
80
79
*/
81
- public function show (Request $ request , object $ model ): bool | Response
80
+ public function show (Request $ request , object $ model ): bool
82
81
{
83
82
if ($ this ->mustAuthorize ()) {
84
- return $ this ->gate ->inspect (
83
+ return $ this ->gate ->check (
85
84
'view ' ,
86
85
$ model
87
86
);
@@ -93,10 +92,10 @@ public function show(Request $request, object $model): bool|Response
93
92
/**
94
93
* @inheritDoc
95
94
*/
96
- public function update (Request $ request , object $ model ): bool | Response
95
+ public function update (Request $ request , object $ model ): bool
97
96
{
98
97
if ($ this ->mustAuthorize ()) {
99
- return $ this ->gate ->inspect (
98
+ return $ this ->gate ->check (
100
99
'update ' ,
101
100
$ model
102
101
);
@@ -108,10 +107,10 @@ public function update(Request $request, object $model): bool|Response
108
107
/**
109
108
* @inheritDoc
110
109
*/
111
- public function destroy (Request $ request , object $ model ): bool | Response
110
+ public function destroy (Request $ request , object $ model ): bool
112
111
{
113
112
if ($ this ->mustAuthorize ()) {
114
- return $ this ->gate ->inspect (
113
+ return $ this ->gate ->check (
115
114
'delete ' ,
116
115
$ model
117
116
);
@@ -123,10 +122,10 @@ public function destroy(Request $request, object $model): bool|Response
123
122
/**
124
123
* @inheritDoc
125
124
*/
126
- public function showRelated (Request $ request , object $ model , string $ fieldName ): bool | Response
125
+ public function showRelated (Request $ request , object $ model , string $ fieldName ): bool
127
126
{
128
127
if ($ this ->mustAuthorize ()) {
129
- return $ this ->gate ->inspect (
128
+ return $ this ->gate ->check (
130
129
'view ' . Str::classify ($ fieldName ),
131
130
$ model
132
131
);
@@ -138,18 +137,18 @@ public function showRelated(Request $request, object $model, string $fieldName):
138
137
/**
139
138
* @inheritDoc
140
139
*/
141
- public function showRelationship (Request $ request , object $ model , string $ fieldName ): bool | Response
140
+ public function showRelationship (Request $ request , object $ model , string $ fieldName ): bool
142
141
{
143
142
return $ this ->showRelated ($ request , $ model , $ fieldName );
144
143
}
145
144
146
145
/**
147
146
* @inheritDoc
148
147
*/
149
- public function updateRelationship (Request $ request , object $ model , string $ fieldName ): bool | Response
148
+ public function updateRelationship (Request $ request , object $ model , string $ fieldName ): bool
150
149
{
151
150
if ($ this ->mustAuthorize ()) {
152
- return $ this ->gate ->inspect (
151
+ return $ this ->gate ->check (
153
152
'update ' . Str::classify ($ fieldName ),
154
153
[$ model , $ this ->createRelation ($ request , $ fieldName )]
155
154
);
@@ -161,10 +160,10 @@ public function updateRelationship(Request $request, object $model, string $fiel
161
160
/**
162
161
* @inheritDoc
163
162
*/
164
- public function attachRelationship (Request $ request , object $ model , string $ fieldName ): bool | Response
163
+ public function attachRelationship (Request $ request , object $ model , string $ fieldName ): bool
165
164
{
166
165
if ($ this ->mustAuthorize ()) {
167
- return $ this ->gate ->inspect (
166
+ return $ this ->gate ->check (
168
167
'attach ' . Str::classify ($ fieldName ),
169
168
[$ model , $ this ->createRelation ($ request , $ fieldName )]
170
169
);
@@ -176,10 +175,10 @@ public function attachRelationship(Request $request, object $model, string $fiel
176
175
/**
177
176
* @inheritDoc
178
177
*/
179
- public function detachRelationship (Request $ request , object $ model , string $ fieldName ): bool | Response
178
+ public function detachRelationship (Request $ request , object $ model , string $ fieldName ): bool
180
179
{
181
180
if ($ this ->mustAuthorize ()) {
182
- return $ this ->gate ->inspect (
181
+ return $ this ->gate ->check (
183
182
'detach ' . Str::classify ($ fieldName ),
184
183
[$ model , $ this ->createRelation ($ request , $ fieldName )]
185
184
);
0 commit comments