From 37e86a792a99a698f643f3f07302fa0e0c65c40c Mon Sep 17 00:00:00 2001 From: Manoj Hortulanus Date: Wed, 2 Apr 2025 14:43:35 +0200 Subject: [PATCH 1/3] Check if is array --- src/Resources/SuppressionResource.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Resources/SuppressionResource.php b/src/Resources/SuppressionResource.php index 7fe2cc5..cacc000 100644 --- a/src/Resources/SuppressionResource.php +++ b/src/Resources/SuppressionResource.php @@ -101,14 +101,14 @@ public static function table(Table $table): Table ->columns([ Tables\Columns\TextColumn::make('to') ->label(__('Email address')) - ->formatStateUsing(fn ($record) => key(json_decode($record->to ?? []))) + ->formatStateUsing(fn($record) => key(json_decode($record->to ?? []))) ->searchable(['to']), Tables\Columns\TextColumn::make('id') ->label(__('Reason')) ->badge() - ->formatStateUsing(fn ($record) => $record->type->value == EventType::COMPLAINED->value ? 'Complained' : 'Bounced') - ->color(fn ($record): string => match ($record->type->value == EventType::COMPLAINED->value) { + ->formatStateUsing(fn($record) => $record->type->value == EventType::COMPLAINED->value ? 'Complained' : 'Bounced') + ->color(fn($record): string => match ($record->type->value == EventType::COMPLAINED->value) { true => 'danger', default => 'gray', }), @@ -117,7 +117,7 @@ public static function table(Table $table): Table ->label(__('Occurred At')) ->dateTime('d-m-Y H:i') ->since() - ->tooltip(fn (MailEvent $record) => $record->occurred_at->format('d-m-Y H:i')) + ->tooltip(fn(MailEvent $record) => $record->occurred_at->format('d-m-Y H:i')) ->sortable() ->searchable(), ]) @@ -125,9 +125,9 @@ public static function table(Table $table): Table Tables\Actions\Action::make('unsuppress') ->label(__('Unsuppress')) ->action(function (MailEvent $record) { - event(new MailUnsuppressed(key($record->to), $record->mail->mailer == 'smtp' && filled($record->mail->transport) ? $record->mail->transport : $record->mail->mailer, $record->mail->stream_id ?? null)); + event(new MailUnsuppressed(is_array($record->to) ? key($record->to) : $record->to, $record->mail->mailer == 'smtp' && filled($record->mail->transport) ? $record->mail->transport : $record->mail->mailer, $record->mail->stream_id ?? null)); }) - ->visible(fn ($record) => Provider::tryFrom($record->mail->mailer == 'smtp' && filled($record->mail->transport) ? $record->mail->transport : $record->mail->mailer)), + ->visible(fn($record) => Provider::tryFrom($record->mail->mailer == 'smtp' && filled($record->mail->transport) ? $record->mail->transport : $record->mail->mailer)), Tables\Actions\ViewAction::make() ->url(null) @@ -136,7 +136,7 @@ public static function table(Table $table): Table ->label(__('View')) ->hiddenLabel() ->tooltip(__('View')) - ->infolist(fn (Infolist $infolist) => EventResource::infolist($infolist)), + ->infolist(fn(Infolist $infolist) => EventResource::infolist($infolist)), ]); } From a65183895ef08abd4bbff472b04c45742835b7eb Mon Sep 17 00:00:00 2001 From: arduinomaster22 <91618246+arduinomaster22@users.noreply.github.com> Date: Wed, 2 Apr 2025 12:43:57 +0000 Subject: [PATCH 2/3] Fix styling --- src/Resources/SuppressionResource.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Resources/SuppressionResource.php b/src/Resources/SuppressionResource.php index cacc000..ff07d16 100644 --- a/src/Resources/SuppressionResource.php +++ b/src/Resources/SuppressionResource.php @@ -101,14 +101,14 @@ public static function table(Table $table): Table ->columns([ Tables\Columns\TextColumn::make('to') ->label(__('Email address')) - ->formatStateUsing(fn($record) => key(json_decode($record->to ?? []))) + ->formatStateUsing(fn ($record) => key(json_decode($record->to ?? []))) ->searchable(['to']), Tables\Columns\TextColumn::make('id') ->label(__('Reason')) ->badge() - ->formatStateUsing(fn($record) => $record->type->value == EventType::COMPLAINED->value ? 'Complained' : 'Bounced') - ->color(fn($record): string => match ($record->type->value == EventType::COMPLAINED->value) { + ->formatStateUsing(fn ($record) => $record->type->value == EventType::COMPLAINED->value ? 'Complained' : 'Bounced') + ->color(fn ($record): string => match ($record->type->value == EventType::COMPLAINED->value) { true => 'danger', default => 'gray', }), @@ -117,7 +117,7 @@ public static function table(Table $table): Table ->label(__('Occurred At')) ->dateTime('d-m-Y H:i') ->since() - ->tooltip(fn(MailEvent $record) => $record->occurred_at->format('d-m-Y H:i')) + ->tooltip(fn (MailEvent $record) => $record->occurred_at->format('d-m-Y H:i')) ->sortable() ->searchable(), ]) @@ -127,7 +127,7 @@ public static function table(Table $table): Table ->action(function (MailEvent $record) { event(new MailUnsuppressed(is_array($record->to) ? key($record->to) : $record->to, $record->mail->mailer == 'smtp' && filled($record->mail->transport) ? $record->mail->transport : $record->mail->mailer, $record->mail->stream_id ?? null)); }) - ->visible(fn($record) => Provider::tryFrom($record->mail->mailer == 'smtp' && filled($record->mail->transport) ? $record->mail->transport : $record->mail->mailer)), + ->visible(fn ($record) => Provider::tryFrom($record->mail->mailer == 'smtp' && filled($record->mail->transport) ? $record->mail->transport : $record->mail->mailer)), Tables\Actions\ViewAction::make() ->url(null) @@ -136,7 +136,7 @@ public static function table(Table $table): Table ->label(__('View')) ->hiddenLabel() ->tooltip(__('View')) - ->infolist(fn(Infolist $infolist) => EventResource::infolist($infolist)), + ->infolist(fn (Infolist $infolist) => EventResource::infolist($infolist)), ]); } From 38c933b96193b56c82b6f6c1e95d1ecc7f6c2590 Mon Sep 17 00:00:00 2001 From: Manoj Hortulanus Date: Fri, 4 Apr 2025 14:27:15 +0200 Subject: [PATCH 3/3] Fix --- src/Resources/SuppressionResource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Resources/SuppressionResource.php b/src/Resources/SuppressionResource.php index cacc000..87636a8 100644 --- a/src/Resources/SuppressionResource.php +++ b/src/Resources/SuppressionResource.php @@ -125,7 +125,7 @@ public static function table(Table $table): Table Tables\Actions\Action::make('unsuppress') ->label(__('Unsuppress')) ->action(function (MailEvent $record) { - event(new MailUnsuppressed(is_array($record->to) ? key($record->to) : $record->to, $record->mail->mailer == 'smtp' && filled($record->mail->transport) ? $record->mail->transport : $record->mail->mailer, $record->mail->stream_id ?? null)); + event(new MailUnsuppressed(is_array($record->to) ? key($record->to) : key(json_decode($record->to, true)), $record->mail->mailer == 'smtp' && filled($record->mail->transport) ? $record->mail->transport : $record->mail->mailer, $record->mail->stream_id ?? null)); }) ->visible(fn($record) => Provider::tryFrom($record->mail->mailer == 'smtp' && filled($record->mail->transport) ? $record->mail->transport : $record->mail->mailer)),