15
15
use Illuminate \Auth \AuthenticationException ;
16
16
use Illuminate \Contracts \Auth \Access \Gate ;
17
17
use Illuminate \Contracts \Auth \Guard ;
18
+ use Illuminate \Auth \Access \Response ;
18
19
use Illuminate \Http \Request ;
19
20
use LaravelJsonApi \Contracts \Auth \Authorizer as AuthorizerContract ;
20
21
use LaravelJsonApi \Contracts \Schema \Schema ;
@@ -41,10 +42,10 @@ public function __construct(
41
42
/**
42
43
* @inheritDoc
43
44
*/
44
- public function index (?Request $ request , string $ modelClass ): bool
45
+ public function index (?Request $ request , string $ modelClass ): bool | Response
45
46
{
46
47
if ($ this ->mustAuthorize ()) {
47
- return $ this ->gate ->check (
48
+ return $ this ->gate ->inspect (
48
49
'viewAny ' ,
49
50
$ modelClass
50
51
);
@@ -56,10 +57,10 @@ public function index(?Request $request, string $modelClass): bool
56
57
/**
57
58
* @inheritDoc
58
59
*/
59
- public function store (?Request $ request , string $ modelClass ): bool
60
+ public function store (?Request $ request , string $ modelClass ): bool | Response
60
61
{
61
62
if ($ this ->mustAuthorize ()) {
62
- return $ this ->gate ->check (
63
+ return $ this ->gate ->inspect (
63
64
'create ' ,
64
65
$ modelClass
65
66
);
@@ -71,10 +72,10 @@ public function store(?Request $request, string $modelClass): bool
71
72
/**
72
73
* @inheritDoc
73
74
*/
74
- public function show (?Request $ request , object $ model ): bool
75
+ public function show (?Request $ request , object $ model ): bool | Response
75
76
{
76
77
if ($ this ->mustAuthorize ()) {
77
- return $ this ->gate ->check (
78
+ return $ this ->gate ->inspect (
78
79
'view ' ,
79
80
$ model
80
81
);
@@ -86,10 +87,10 @@ public function show(?Request $request, object $model): bool
86
87
/**
87
88
* @inheritDoc
88
89
*/
89
- public function update (Request $ request , object $ model ): bool
90
+ public function update (Request $ request , object $ model ): bool | Response
90
91
{
91
92
if ($ this ->mustAuthorize ()) {
92
- return $ this ->gate ->check (
93
+ return $ this ->gate ->inspect (
93
94
'update ' ,
94
95
$ model
95
96
);
@@ -101,10 +102,10 @@ public function update(Request $request, object $model): bool
101
102
/**
102
103
* @inheritDoc
103
104
*/
104
- public function destroy (Request $ request , object $ model ): bool
105
+ public function destroy (Request $ request , object $ model ): bool | Response
105
106
{
106
107
if ($ this ->mustAuthorize ()) {
107
- return $ this ->gate ->check (
108
+ return $ this ->gate ->inspect (
108
109
'delete ' ,
109
110
$ model
110
111
);
@@ -116,10 +117,10 @@ public function destroy(Request $request, object $model): bool
116
117
/**
117
118
* @inheritDoc
118
119
*/
119
- public function showRelated (Request $ request , object $ model , string $ fieldName ): bool
120
+ public function showRelated (Request $ request , object $ model , string $ fieldName ): bool | Response
120
121
{
121
122
if ($ this ->mustAuthorize ()) {
122
- return $ this ->gate ->check (
123
+ return $ this ->gate ->inspect (
123
124
'view ' . Str::classify ($ fieldName ),
124
125
$ model
125
126
);
@@ -131,18 +132,18 @@ public function showRelated(Request $request, object $model, string $fieldName):
131
132
/**
132
133
* @inheritDoc
133
134
*/
134
- public function showRelationship (Request $ request , object $ model , string $ fieldName ): bool
135
+ public function showRelationship (Request $ request , object $ model , string $ fieldName ): bool | Response
135
136
{
136
137
return $ this ->showRelated ($ request , $ model , $ fieldName );
137
138
}
138
139
139
140
/**
140
141
* @inheritDoc
141
142
*/
142
- public function updateRelationship (Request $ request , object $ model , string $ fieldName ): bool
143
+ public function updateRelationship (Request $ request , object $ model , string $ fieldName ): bool | Response
143
144
{
144
145
if ($ this ->mustAuthorize ()) {
145
- return $ this ->gate ->check (
146
+ return $ this ->gate ->inspect (
146
147
'update ' . Str::classify ($ fieldName ),
147
148
[$ model , $ this ->createRelation ($ request , $ fieldName )]
148
149
);
@@ -154,10 +155,10 @@ public function updateRelationship(Request $request, object $model, string $fiel
154
155
/**
155
156
* @inheritDoc
156
157
*/
157
- public function attachRelationship (Request $ request , object $ model , string $ fieldName ): bool
158
+ public function attachRelationship (Request $ request , object $ model , string $ fieldName ): bool | Response
158
159
{
159
160
if ($ this ->mustAuthorize ()) {
160
- return $ this ->gate ->check (
161
+ return $ this ->gate ->inspect (
161
162
'attach ' . Str::classify ($ fieldName ),
162
163
[$ model , $ this ->createRelation ($ request , $ fieldName )]
163
164
);
@@ -169,10 +170,10 @@ public function attachRelationship(Request $request, object $model, string $fiel
169
170
/**
170
171
* @inheritDoc
171
172
*/
172
- public function detachRelationship (Request $ request , object $ model , string $ fieldName ): bool
173
+ public function detachRelationship (Request $ request , object $ model , string $ fieldName ): bool | Response
173
174
{
174
175
if ($ this ->mustAuthorize ()) {
175
- return $ this ->gate ->check (
176
+ return $ this ->gate ->inspect (
176
177
'detach ' . Str::classify ($ fieldName ),
177
178
[$ model , $ this ->createRelation ($ request , $ fieldName )]
178
179
);
0 commit comments