Skip to content

Commit

Permalink
refactor: Filament Pages & ChangelogResource
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiorodriguesroque committed Nov 11, 2024
1 parent 9a8080e commit b4c7b9b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
11 changes: 9 additions & 2 deletions app/Filament/Pages/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Filament\Pages;

use App\Enums\UserRole;
use App\Models\User;
use Filament\Pages\Page;
use Filament\Actions\Action;
use App\Services\SystemChecker;
Expand Down Expand Up @@ -36,12 +37,18 @@ public function getHeading(): string|Htmlable

public static function shouldRegisterNavigation(): bool
{
return auth()->user()->hasRole(UserRole::Admin);
/** @var User $user */
$user = auth()->user();

return $user->hasRole(UserRole::Admin);
}

public function mount(): void
{
abort_unless(auth()->user()->hasRole(UserRole::Admin), 403);
/** @var User $user */
$user = auth()->user();

abort_unless($user->hasRole(UserRole::Admin), 403);
}

protected function getHeaderWidgets(): array
Expand Down
5 changes: 4 additions & 1 deletion app/Filament/Pages/Widgets/System/SystemInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ class SystemInfo extends Widget

protected int | string | array $columnSpan = 2;

/**
* @var array<string, mixed>
*/
public array $version = [
'remoteVersion' => 0,
'currentVersion' => 0
];
public bool $isOutOfDate = false;
public string $phpVersion = '8.1';

public function mount()
public function mount(): void
{
$systemChecker = (new SystemChecker);

Expand Down
2 changes: 1 addition & 1 deletion app/Filament/Resources/ChangelogResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static function form(Form $form): Form
Select::make('user_id')
->label(trans('resources.changelog.author'))
->relationship('user', 'name')
->default(auth()->user()->id)
->default(auth()->user()?->id)
->preload()
->required()
->searchable(),
Expand Down

0 comments on commit b4c7b9b

Please sign in to comment.