Skip to content

Commit

Permalink
patch
Browse files Browse the repository at this point in the history
  • Loading branch information
AnourValar committed Jul 5, 2023
1 parent 73f96ea commit f623f39
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/ModelTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,14 +373,21 @@ public function scopeAddPublishFields()
/**
* Determine if the user has the given abilities related to the entity.
*
* @param iterable|string|null $abilities
* @param string $relation = null
* @param iterable|string|null $abilities
* @param string|null $relation
* @return \Illuminate\Support\HigherOrderTapProxy<\Illuminate\Database\Eloquent\Model>
*/
public function authorize($abilities, string $relation = null)
{
if (isset($abilities)) {
app(\Illuminate\Contracts\Auth\Access\Gate::class)->authorize($abilities, ($relation ? $this->$relation : $this));
$arg = $this;
if ($relation) {
foreach (explode('.', $relation) as $item) {
$arg = $arg->$item;
}
}

app(\Illuminate\Contracts\Auth\Access\Gate::class)->authorize($abilities, $arg);
}

return tap($this);
Expand Down

0 comments on commit f623f39

Please sign in to comment.