Skip to content

Commit

Permalink
Merge branch 'main' of github.com:vormkracht10/filament-mails
Browse files Browse the repository at this point in the history
  • Loading branch information
Baspa committed Aug 30, 2024
2 parents 7bbc965 + 6e83baa commit a969f0a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 33 deletions.
17 changes: 8 additions & 9 deletions src/FilamentMailsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

namespace Vormkracht10\FilamentMails;

use Filament\Panel;
use Filament\Contracts\Plugin;
use Filament\Facades\Filament;
use Filament\Support\Colors\Color;
use Filament\Navigation\NavigationItem;
use Vormkracht10\FilamentMails\Resources\MailResource;
use Filament\Panel;
use Filament\Support\Colors\Color;
use Vormkracht10\FilamentMails\Resources\EventResource;
use Vormkracht10\FilamentMails\Widgets\BouncerateWidget;
use Vormkracht10\FilamentMails\Resources\MailResource;

class FilamentMailsPlugin implements Plugin
{
Expand All @@ -35,16 +34,16 @@ public function boot(Panel $panel): void
NavigationItem::make()
->group(__('Mails'))
->label('Mails')
->url(fn(): string => MailResource::getUrl('index'))
->url(fn (): string => MailResource::getUrl('index'))
->icon('heroicon-o-envelope')
->isActiveWhen(fn(): bool => request()->routeIs('filament.' . $panel->getId() . '.resources.mails.*'))
->isActiveWhen(fn (): bool => request()->routeIs('filament.' . $panel->getId() . '.resources.mails.*'))
->childItems([
NavigationItem::make()
->label('Events')
->url(fn(): string => EventResource::getUrl('index'))
->url(fn (): string => EventResource::getUrl('index'))
->icon('heroicon-o-calendar')
->isActiveWhen(fn(): bool => request()->routeIs('filament.' . $panel->getId() . '.resources.events.*'))
])
->isActiveWhen(fn (): bool => request()->routeIs('filament.' . $panel->getId() . '.resources.events.*')),
]),
]);
});
}
Expand Down
6 changes: 2 additions & 4 deletions src/Resources/EventResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

namespace Vormkracht10\FilamentMails\Resources;

use Filament\Tables;
use Filament\Tables\Table;
use Filament\Infolists\Infolist;
use Filament\Resources\Resource;
use Filament\Resources\Pages\Page;
use Vormkracht10\FilamentMails\Resources\MailResource\Pages\ListMails;
use Filament\Tables;
use Filament\Tables\Table;
use Vormkracht10\FilamentMails\Resources\EventResource\Pages\ListEvents;
use Vormkracht10\Mails\Models\MailEvent;

Expand Down
3 changes: 0 additions & 3 deletions src/Resources/EventResource/Pages/ListEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@

use Filament\Resources\Components\Tab;
use Filament\Resources\Pages\ListRecords;
use Illuminate\Database\Eloquent\Builder;
use Vormkracht10\FilamentMails\Models\Mail;
use Vormkracht10\FilamentMails\Resources\EventResource;
use Vormkracht10\FilamentMails\Widgets\BouncerateWidget;
use Vormkracht10\Mails\Models\MailEvent;

class ListEvents extends ListRecords
Expand Down
28 changes: 13 additions & 15 deletions src/Resources/MailResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@

namespace Vormkracht10\FilamentMails\Resources;

use Filament\Tables;
use Filament\Tables\Table;
use Filament\Infolists\Infolist;
use Filament\Resources\Resource;
use Filament\Resources\Pages\Page;
use Filament\Infolists\Components\Grid;
use Filament\Infolists\Components\Tabs;
use Filament\Infolists\Components\Section;
use Filament\Infolists\Components\Tabs;
use Filament\Infolists\Components\Tabs\Tab;
use Vormkracht10\FilamentMails\Models\Mail;
use Filament\Infolists\Components\TextEntry;
use Filament\Infolists\Infolist;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Vormkracht10\FilamentMails\Models\Mail;
use Vormkracht10\FilamentMails\Resources\MailResource\Pages\ListMails;
use Vormkracht10\FilamentMails\Resources\MailResource\Pages\ListEvents;

class MailResource extends Resource
{
Expand Down Expand Up @@ -62,22 +60,22 @@ public static function infolist(Infolist $infolist): Infolist
->label(__('Subject')),
TextEntry::make('from')
->label(__('From'))
->formatStateUsing(fn($state) => self::formatEmailAddress($state)),
->formatStateUsing(fn ($state) => self::formatEmailAddress($state)),
TextEntry::make('to')
->label(__('Recipient'))
->formatStateUsing(fn($state) => self::formatEmailAddress($state)),
->formatStateUsing(fn ($state) => self::formatEmailAddress($state)),
TextEntry::make('cc')
->label(__('CC'))
->default('-')
->formatStateUsing(fn($state) => self::formatEmailAddress($state)),
->formatStateUsing(fn ($state) => self::formatEmailAddress($state)),
TextEntry::make('bcc')
->label(__('BCC'))
->default('-')
->formatStateUsing(fn($state) => self::formatEmailAddress($state)),
->formatStateUsing(fn ($state) => self::formatEmailAddress($state)),
TextEntry::make('reply_to')
->default('-')
->label(__('Reply To'))
->formatStateUsing(fn($state) => self::formatEmailAddress($state)),
->formatStateUsing(fn ($state) => self::formatEmailAddress($state)),
]),
]),
Section::make('Content')
Expand Down Expand Up @@ -167,7 +165,7 @@ public static function table(Table $table): Table
->label(__('Status'))
->sortable()
->badge()
->color(fn(string $state): string => match ($state) {
->color(fn (string $state): string => match ($state) {
'Hard Bounced' => 'danger',
'Soft Bounced' => 'warning',
'Complained' => 'danger',
Expand All @@ -186,7 +184,7 @@ public static function table(Table $table): Table
->searchable(),
Tables\Columns\TextColumn::make('to')
->label(__('Recipient'))
->formatStateUsing(fn($state) => self::formatEmailAddressForTable($state))
->formatStateUsing(fn ($state) => self::formatEmailAddressForTable($state))
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('sent_at')
Expand Down
4 changes: 2 additions & 2 deletions src/Widgets/BouncerateWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class BouncerateWidget extends BaseWidget

protected function getStats(): array
{
$bouncedMails = Mail::where(fn($query) => $query->softBounced()->orWhere(fn($query) => $query->hardBounced()))->count();
$bouncedMails = Mail::where(fn ($query) => $query->softBounced()->orWhere(fn ($query) => $query->hardBounced()))->count();
$openedMails = Mail::opened()->count();
$deliveredMails = Mail::delivered()->count();
$clickedMails = Mail::clicked()->count();
Expand Down Expand Up @@ -43,4 +43,4 @@ protected function getStats(): array

return $widgets;
}
}
}

0 comments on commit a969f0a

Please sign in to comment.