Skip to content

Commit 90a49e3

Browse files
committed
refactor: remove unused can method and related documentation from Relation.php
1 parent bd6308d commit 90a49e3

File tree

2 files changed

+0
-33
lines changed

2 files changed

+0
-33
lines changed

readme.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -331,20 +331,6 @@ protected function toRelationships(Request $request): array
331331
}
332332
```
333333

334-
#### Laravel policy on relationships
335-
_**@see** [laravel: authorizing-actions-via-gates](https://laravel.com/docs/12.x/authorization#authorizing-actions-via-gates)_
336-
337-
Apply laravel policy on relationships.
338-
339-
```php
340-
protected function toRelationships(Request $request): array
341-
{
342-
return [
343-
'posts' => $this->many(PostResource::class)
344-
->can('viewAny.post')
345-
];
346-
}
347-
```
348334

349335
### toLinks
350336
_**@see** [{json:api}: resource-linkage](https://jsonapi.org/format/#document-resource-object-links)_

src/Descriptors/Relations/Relation.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Ark4ne\JsonApi\Support\Includes;
88
use Ark4ne\JsonApi\Traits\HasRelationLoad;
99
use Closure;
10-
use Illuminate\Contracts\Auth\Access\Gate;
1110
use Illuminate\Database\Eloquent\Model;
1211
use Illuminate\Http\Request;
1312
use Illuminate\Http\Resources\MissingValue;
@@ -64,24 +63,6 @@ public function meta(Closure $meta): static
6463
return $this;
6564
}
6665

67-
/**
68-
* @param iterable<mixed>|string $abilities Abilities to check
69-
* @param array<mixed> $arguments Arguments to pass to the policy method, the model is always the first argument
70-
* @param string $gateClass Gate class to use, defaults to the default Gate implementation
71-
* @return static
72-
*/
73-
public function can(iterable|string $abilities, array $arguments = [], string $gateClass = Gate::class): static
74-
{
75-
return $this->when(fn(
76-
Request $request,
77-
Model $model,
78-
string $attribute
79-
) => app($gateClass)
80-
->forUser($request->user())
81-
->allows($abilities, [$model, ...$arguments])
82-
);
83-
}
84-
8566
/**
8667
* @param bool|null $whenIncluded
8768
* @return static

0 commit comments

Comments
 (0)