From 88cbe37712aa12137c0f5f615a5d4e4d5dee0870 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Wed, 23 Jul 2025 09:13:16 +0200 Subject: [PATCH] fix form for webhooks --- .../Admin/Resources/WebhookResource.php | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/app/Filament/Admin/Resources/WebhookResource.php b/app/Filament/Admin/Resources/WebhookResource.php index 29f73b168..eae819018 100644 --- a/app/Filament/Admin/Resources/WebhookResource.php +++ b/app/Filament/Admin/Resources/WebhookResource.php @@ -132,14 +132,15 @@ class WebhookResource extends Resource ->live() ->inline() ->options(WebhookType::class) - ->default(WebhookType::Regular->value) - ->afterStateHydrated(function (string $state) { - if ($state === WebhookType::Discord->value) { + ->default(WebhookType::Regular) + ->afterStateHydrated(function (WebhookType $state) { + if ($state === WebhookType::Discord) { self::sendHelpBanner(); } }) - ->afterStateUpdated(function (string $state) { - if ($state === WebhookType::Discord->value) { + ->afterStateUpdated(function (WebhookType $state) { + if ($state === WebhookType::Discord) { + self::sendHelpBanner(); } }), TextInput::make('description') @@ -150,23 +151,26 @@ class WebhookResource extends Resource ->activeUrl() ->required() ->columnSpanFull() - ->afterStateUpdated(fn (string $state, Set $set) => $set('type', str($state)->contains('discord.com') ? WebhookType::Discord->value : WebhookType::Regular->value)), + ->afterStateUpdated(fn (string $state, Set $set) => $set('type', str($state)->contains('discord.com') ? WebhookType::Discord : WebhookType::Regular)), Section::make(trans('admin/webhook.regular')) - ->hidden(fn (Get $get) => $get('type') === WebhookType::Discord->value) + ->hidden(fn (Get $get) => $get('type') === WebhookType::Discord) ->dehydratedWhenHidden() ->schema(fn () => self::getRegularFields()) - ->formBefore(), + ->formBefore() + ->columnSpanFull(), Section::make(trans('admin/webhook.discord')) - ->hidden(fn (Get $get) => $get('type') === WebhookType::Regular->value) + ->hidden(fn (Get $get) => $get('type') === WebhookType::Regular) ->dehydratedWhenHidden() ->afterStateUpdated(fn (Livewire $livewire) => $livewire->dispatch('refresh-widget')) ->schema(fn () => self::getDiscordFields()) ->view('filament.components.webhooksection') ->aside() - ->formBefore(), + ->formBefore() + ->columnSpanFull(), Section::make(trans('admin/webhook.events')) ->collapsible() ->collapsed(fn (Get $get) => count($get('events') ?? [])) + ->columnSpanFull() ->schema([ CheckboxList::make('events') ->live()