Skip to content

Commit 1d469c4

Browse files
committed
feat: revoke overriding policies as against core Laravel logic
1 parent 3f08df8 commit 1d469c4

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

src/Http/Api/Contracts/HasParser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
/**
1212
* @property \Illuminate\Http\Request $request
1313
* @property string|array<string,string>|null $parentModel
14-
* @property string|null $parentPolicy
1514
*/
1615
trait HasParser
1716
{
@@ -74,7 +73,8 @@ protected function filterByParent(): array
7473
$routeRelation = $child->{$key}()->getRelated()->where($bindingField, $routeRelation)->firstOrFail();
7574
}
7675

77-
$parentPolicy = $this->parentPolicy ?? Gate::getPolicyFor($routeRelation);
76+
$parentPolicy = Gate::getPolicyFor($routeRelation);
77+
7878
if(!is_null($parentPolicy)){
7979
$this->authorize('view', $routeRelation);
8080
}

src/Http/Api/Contracts/HasPolicies.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77
trait HasPolicies
88
{
99

10-
/**
11-
* @var class-string|null $resourcePolicy
12-
*/
13-
protected ?string $resourcePolicy = null;
14-
1510
/**
1611
* Qualifies the collection query to allow you to add params vai the policy
1712
* ie to limit to a specific user id mapping.
@@ -122,7 +117,7 @@ protected function testUserPolicyAction(string $ability, $arguments = null, bool
122117
$model = $arguments;
123118
}
124119

125-
$modelPolicy = $this->resourcePolicy ?? Gate::getPolicyFor($model);
120+
$modelPolicy = Gate::getPolicyFor($model);
126121

127122
// If no policy exists for this model, then there's nothing to check
128123
if (is_null($modelPolicy) || ($excludeMissing && ! method_exists($modelPolicy, $ability))) {

0 commit comments

Comments
 (0)