Skip to content

Commit

Permalink
Merge pull request #39 from niekbr/feature/restore-authorization
Browse files Browse the repository at this point in the history
Extract restore authorization
  • Loading branch information
pxlrbt authored Apr 3, 2024
2 parents 44ac38c + 0107d44 commit 9019cea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion resources/views/pages/list-activities.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</div>
</div>
<div class="flex flex-col text-xs text-gray-500 justify-end">
@if (static::getResource()::canRestore($record))
@if ($this->canRestoreActivity())
<x-filament::button
tag="button"
icon="heroicon-o-arrow-path-rounded-square"
Expand Down
7 changes: 6 additions & 1 deletion src/Pages/ListActivities.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,14 @@ protected function createFieldLabelMap(): Collection
]);
}

public function canRestoreActivity(): bool
{
return static::getResource()::canRestore($this->record);
}

public function restoreActivity(int|string $key)
{
if (! static::getResource()::canRestore($this->record)) {
if (! $this->canRestoreActivity()) {
abort(403);
}

Expand Down

0 comments on commit 9019cea

Please sign in to comment.