Skip to content

Commit

Permalink
small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy132 committed Sep 18, 2024
1 parent 22442cb commit 4f63cda
Showing 1 changed file with 6 additions and 35 deletions.
41 changes: 6 additions & 35 deletions app/Filament/Pages/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Filament\Pages;

use App\Models\Backup;
use App\Models\User;
use App\Notifications\MailTested;
use App\Traits\EnvironmentWriterTrait;
use Exception;
Expand Down Expand Up @@ -52,10 +51,7 @@ public function mount(): void

public static function canAccess(): bool
{
/** @var User $user */
$user = auth()->user();

return $user->can('view settings');
return auth()->user()->can('view settings');
}

protected function getFormSchema(): array
Expand All @@ -64,12 +60,7 @@ protected function getFormSchema(): array
Tabs::make('Tabs')
->columns()
->persistTabInQueryString()
->disabled(function () {
/** @var User $user */
$user = auth()->user();

return !$user->can('update settings');
})
->disabled(fn () => !auth()->user()->can('update settings'))
->tabs([
Tab::make('general')
->label('General')
Expand Down Expand Up @@ -162,22 +153,12 @@ private function generalSettings(): array
->color('danger')
->icon('tabler-trash')
->requiresConfirmation()
->disabled(function () {
/** @var User $user */
$user = auth()->user();

return !$user->can('update settings');
})
->authorize(fn () => auth()->user()->can('update settings'))
->action(fn (Set $set) => $set('TRUSTED_PROXIES', [])),
FormAction::make('cloudflare')
->label('Set to Cloudflare IPs')
->icon('tabler-brand-cloudflare')
->disabled(function () {
/** @var User $user */
$user = auth()->user();

return !$user->can('update settings');
})
->authorize(fn () => auth()->user()->can('update settings'))
->action(fn (Set $set) => $set('TRUSTED_PROXIES', [
'173.245.48.0/20',
'103.21.244.0/22',
Expand Down Expand Up @@ -253,12 +234,7 @@ private function mailSettings(): array
->label('Send Test Mail')
->icon('tabler-send')
->hidden(fn (Get $get) => $get('MAIL_MAILER') === 'log')
->disabled(function () {
/** @var User $user */
$user = auth()->user();

return !$user->can('update settings');
})
->authorize(fn () => auth()->user()->can('update settings'))
->action(function () {
try {
MailNotification::route('mail', auth()->user()->email)
Expand Down Expand Up @@ -594,12 +570,7 @@ protected function getHeaderActions(): array
return [
Action::make('save')
->action('save')
->hidden(function () {
/** @var User $user */
$user = auth()->user();

return !$user->can('update settings');
})
->authorize(fn () => auth()->user()->can('update settings'))
->keyBindings(['mod+s']),
];

Expand Down

0 comments on commit 4f63cda

Please sign in to comment.