Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
markvaneijk committed Jan 9, 2025
1 parent 2cf4e52 commit b823b03
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 0 deletions.
104 changes: 104 additions & 0 deletions src/Resources/SuppressionResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php

namespace Vormkracht10\FilamentMails\Resources;

use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Vormkracht10\FilamentMails\Resources\SuppressionResource\Pages\ListSuppressions;
use Vormkracht10\FilamentMails\Resources\SuppressionResource\Pages\ViewSuppression;
use Vormkracht10\Mails\Enums\EventType;
use Vormkracht10\Mails\Models\MailEvent;

class SuppressionResource extends Resource
{
protected static ?string $model = MailEvent::class;

protected static ?string $slug = 'mails/suppressions';

protected static bool $isScopedToTenant = false;

protected static bool $shouldRegisterNavigation = true;

public function getTitle(): string
{
return __('Suppressions');
}

public static function getNavigationParentItem(): ?string
{
return __('Mails');
}

public static function getNavigationGroup(): ?string
{
return __('Mails');
}

public static function getNavigationLabel(): string
{
return __('Suppressions');
}

public static function getLabel(): ?string
{
return __('Suppression');
}

public static function getPluralModelLabel(): string
{
return __('Suppressions');
}

public static function getNavigationIcon(): string
{
return 'heroicon-o-no-symbol';
}

public static function table(Table $table): Table
{
return $table
->recordAction('view')
->recordUrl(null)
->defaultSort('created_at', 'desc')
->columns([
Tables\Columns\TextColumn::make('mail.to')
->label(__('Email address'))
->formatStateUsing(fn(MailEvent $record) => key($record->mail->to))
->searchable(['to']),
Tables\Columns\TextColumn::make('occurred_at')
->label(__('Suppressed At'))
->dateTime('d-m-Y H:i')
->since()
->tooltip(fn(MailEvent $record) => $record->occurred_at->format('d-m-Y H:i'))
->sortable()
->searchable(),
])
->modifyQueryUsing(fn($query) => $query->where('type', EventType::HARD_BOUNCED))
->filters([
//
])
->actions([
Tables\Actions\ViewAction::make()
->url(null)
->modal()
->slideOver()
->label(__('View'))
->hiddenLabel()
->tooltip(__('View')),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}

public static function getPages(): array
{
return [
'index' => ListSuppressions::route('/'),
'view' => ViewSuppression::route('/{record}/view'),
];
}
}
21 changes: 21 additions & 0 deletions src/Resources/SuppressionResource/Pages/ListSuppressions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Vormkracht10\FilamentMails\Resources\SuppressionResource\Pages;

use Filament\Resources\Pages\ListRecords;
use Vormkracht10\FilamentMails\Resources\SuppressionResource;

class ListSuppressions extends ListRecords
{
protected static string $resource = SuppressionResource::class;

public function getTitle(): string
{
return __('Suppressions');
}

protected function getActions(): array
{
return [];
}
}
11 changes: 11 additions & 0 deletions src/Resources/SuppressionResource/Pages/ViewSuppression.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Vormkracht10\FilamentMails\Resources\SuppressionResource\Pages;

use Filament\Resources\Pages\ViewRecord;
use Vormkracht10\FilamentMails\Resources\SuppressionResource;

class ViewSuppression extends ViewRecord
{
protected static string $resource = SuppressionResource::class;
}

0 comments on commit b823b03

Please sign in to comment.