Skip to content

Commit

Permalink
refactor: Filament settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiorodriguesroque committed Nov 11, 2024
1 parent be82e92 commit 9a8080e
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions app/Filament/Pages/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Models\Board;
use App\Enums\UserRole;
use App\Models\Project;
use App\Services\OgImage;
use Filament\Forms\Get;
use Filament\Forms\Form;
use Illuminate\Support\Str;
Expand Down Expand Up @@ -53,18 +54,21 @@ public function getHeading(): string|Htmlable
return trans('settings.title');
}

/**
* @var Collection<int, string>
*/
public Collection $ogImages;

public static function shouldRegisterNavigation(): bool
{
return auth()->user()->hasRole(UserRole::Admin);
return auth()->user()?->hasRole(UserRole::Admin) ?? false;
}

public function mount(): void
{
parent::mount();

abort_unless(auth()->user()->hasRole(UserRole::Admin), 403);
abort_unless(auth()->user()?->hasRole(UserRole::Admin) ?? false, 403);

$this->ogImages = collect(Storage::disk('public')->allFiles())
->filter(
Expand Down Expand Up @@ -275,12 +279,10 @@ public function form(Form $form): Form
Select::make('column_span')
->label(trans('settings.dashboard-items.column-span'))
->helperText(trans('settings.dashboard-items.column-span-helper-text'))
->options(
[
1 => 1,
2 => 2,
]
)
->options(fn () => [
1 => 1,
2 => 2,
])
->default(1),

Toggle::make('must_have_project')
Expand Down

0 comments on commit 9a8080e

Please sign in to comment.