Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/actions/src/Concerns/CanBeAuthorized.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Gate;
use LogicException;
use UnitEnum;

trait CanBeAuthorized
{
Expand All @@ -20,7 +21,7 @@ trait CanBeAuthorized

protected bool | Closure $hasAuthorizationNotification = false;

protected bool | string | Closure | null $authorizeIndividualRecords = null;
protected bool | string | UnitEnum | Closure | null $authorizeIndividualRecords = null;

/**
* @param Model | class-string | array<mixed> | null $arguments
Expand Down Expand Up @@ -211,7 +212,7 @@ public function isAuthorizedOrNotHiddenWhenUnauthorized(): bool
return $this->isAuthorized();
}

public function authorizeIndividualRecords(bool | string | Closure | null $callback = true): static
public function authorizeIndividualRecords(bool | string | UnitEnum | Closure | null $callback = true): static
{
$this->authorizeIndividualRecords = $callback;

Expand All @@ -220,7 +221,7 @@ public function authorizeIndividualRecords(bool | string | Closure | null $callb

public function getIndividualRecordAuthorizationResponse(Model $record): Response
{
if (is_string($this->authorizeIndividualRecords)) {
if (is_string($this->authorizeIndividualRecords) || $this->authorizeIndividualRecords instanceof UnitEnum) {
return Gate::inspect($this->authorizeIndividualRecords, Arr::wrap($record));
}

Expand Down