1515use Illuminate \Auth \AuthenticationException ;
1616use Illuminate \Contracts \Auth \Access \Gate ;
1717use Illuminate \Contracts \Auth \Guard ;
18+ use Illuminate \Auth \Access \Response ;
1819use Illuminate \Http \Request ;
1920use LaravelJsonApi \Contracts \Auth \Authorizer as AuthorizerContract ;
2021use LaravelJsonApi \Contracts \Schema \Schema ;
@@ -41,10 +42,10 @@ public function __construct(
4142 /**
4243 * @inheritDoc
4344 */
44- public function index (?Request $ request , string $ modelClass ): bool
45+ public function index (?Request $ request , string $ modelClass ): bool | Response
4546 {
4647 if ($ this ->mustAuthorize ()) {
47- return $ this ->gate ->check (
48+ return $ this ->gate ->inspect (
4849 'viewAny ' ,
4950 $ modelClass
5051 );
@@ -56,10 +57,10 @@ public function index(?Request $request, string $modelClass): bool
5657 /**
5758 * @inheritDoc
5859 */
59- public function store (?Request $ request , string $ modelClass ): bool
60+ public function store (?Request $ request , string $ modelClass ): bool | Response
6061 {
6162 if ($ this ->mustAuthorize ()) {
62- return $ this ->gate ->check (
63+ return $ this ->gate ->inspect (
6364 'create ' ,
6465 $ modelClass
6566 );
@@ -71,10 +72,10 @@ public function store(?Request $request, string $modelClass): bool
7172 /**
7273 * @inheritDoc
7374 */
74- public function show (?Request $ request , object $ model ): bool
75+ public function show (?Request $ request , object $ model ): bool | Response
7576 {
7677 if ($ this ->mustAuthorize ()) {
77- return $ this ->gate ->check (
78+ return $ this ->gate ->inspect (
7879 'view ' ,
7980 $ model
8081 );
@@ -86,10 +87,10 @@ public function show(?Request $request, object $model): bool
8687 /**
8788 * @inheritDoc
8889 */
89- public function update (Request $ request , object $ model ): bool
90+ public function update (Request $ request , object $ model ): bool | Response
9091 {
9192 if ($ this ->mustAuthorize ()) {
92- return $ this ->gate ->check (
93+ return $ this ->gate ->inspect (
9394 'update ' ,
9495 $ model
9596 );
@@ -101,10 +102,10 @@ public function update(Request $request, object $model): bool
101102 /**
102103 * @inheritDoc
103104 */
104- public function destroy (Request $ request , object $ model ): bool
105+ public function destroy (Request $ request , object $ model ): bool | Response
105106 {
106107 if ($ this ->mustAuthorize ()) {
107- return $ this ->gate ->check (
108+ return $ this ->gate ->inspect (
108109 'delete ' ,
109110 $ model
110111 );
@@ -116,10 +117,10 @@ public function destroy(Request $request, object $model): bool
116117 /**
117118 * @inheritDoc
118119 */
119- public function showRelated (Request $ request , object $ model , string $ fieldName ): bool
120+ public function showRelated (Request $ request , object $ model , string $ fieldName ): bool | Response
120121 {
121122 if ($ this ->mustAuthorize ()) {
122- return $ this ->gate ->check (
123+ return $ this ->gate ->inspect (
123124 'view ' . Str::classify ($ fieldName ),
124125 $ model
125126 );
@@ -131,18 +132,18 @@ public function showRelated(Request $request, object $model, string $fieldName):
131132 /**
132133 * @inheritDoc
133134 */
134- public function showRelationship (Request $ request , object $ model , string $ fieldName ): bool
135+ public function showRelationship (Request $ request , object $ model , string $ fieldName ): bool | Response
135136 {
136137 return $ this ->showRelated ($ request , $ model , $ fieldName );
137138 }
138139
139140 /**
140141 * @inheritDoc
141142 */
142- public function updateRelationship (Request $ request , object $ model , string $ fieldName ): bool
143+ public function updateRelationship (Request $ request , object $ model , string $ fieldName ): bool | Response
143144 {
144145 if ($ this ->mustAuthorize ()) {
145- return $ this ->gate ->check (
146+ return $ this ->gate ->inspect (
146147 'update ' . Str::classify ($ fieldName ),
147148 [$ model , $ this ->createRelation ($ request , $ fieldName )]
148149 );
@@ -154,10 +155,10 @@ public function updateRelationship(Request $request, object $model, string $fiel
154155 /**
155156 * @inheritDoc
156157 */
157- public function attachRelationship (Request $ request , object $ model , string $ fieldName ): bool
158+ public function attachRelationship (Request $ request , object $ model , string $ fieldName ): bool | Response
158159 {
159160 if ($ this ->mustAuthorize ()) {
160- return $ this ->gate ->check (
161+ return $ this ->gate ->inspect (
161162 'attach ' . Str::classify ($ fieldName ),
162163 [$ model , $ this ->createRelation ($ request , $ fieldName )]
163164 );
@@ -169,10 +170,10 @@ public function attachRelationship(Request $request, object $model, string $fiel
169170 /**
170171 * @inheritDoc
171172 */
172- public function detachRelationship (Request $ request , object $ model , string $ fieldName ): bool
173+ public function detachRelationship (Request $ request , object $ model , string $ fieldName ): bool | Response
173174 {
174175 if ($ this ->mustAuthorize ()) {
175- return $ this ->gate ->check (
176+ return $ this ->gate ->inspect (
176177 'detach ' . Str::classify ($ fieldName ),
177178 [$ model , $ this ->createRelation ($ request , $ fieldName )]
178179 );
0 commit comments