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 Sep 3, 2024
2 parents 1c170e8 + 1f29e74 commit fa16cf8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/FilamentMailsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,4 @@ protected function getMigrations(): array
'create_filament-mails_table',
];
}
}
}
24 changes: 12 additions & 12 deletions src/Resources/EventResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

namespace Vormkracht10\FilamentMails\Resources;

use Filament\Tables;
use Filament\Tables\Table;
use Filament\Infolists\Infolist;
use Filament\Resources\Resource;
use Filament\Infolists\Components\Grid;
use Vormkracht10\Mails\Models\MailEvent;
use Filament\Infolists\Components\KeyValueEntry;
use Filament\Infolists\Components\Section;
use Filament\Infolists\Components\TextEntry;
use Vormkracht10\Mails\Enums\WebhookEventType;
use Filament\Infolists\Components\KeyValueEntry;
use Filament\Infolists\Infolist;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Vormkracht10\FilamentMails\Resources\EventResource\Pages\ListEvents;
use Vormkracht10\Mails\Enums\WebhookEventType;
use Vormkracht10\Mails\Models\MailEvent;

class EventResource extends Resource
{
Expand Down Expand Up @@ -64,7 +64,7 @@ public static function infolist(Infolist $infolist): Infolist
TextEntry::make('type')
->label(__('Type'))
->badge()
->color(fn(WebhookEventType $state): string => match ($state) {
->color(fn (WebhookEventType $state): string => match ($state) {
WebhookEventType::DELIVERY => 'success',
WebhookEventType::CLICK => 'info',
WebhookEventType::OPEN => 'success',
Expand Down Expand Up @@ -105,7 +105,7 @@ public static function infolist(Infolist $infolist): Infolist
->default(__('Unknown'))
->label(__('User Agent'))
->limit(50)
->tooltip(fn($state) => $state),
->tooltip(fn ($state) => $state),
]),
]),
Section::make(__('Location'))
Expand All @@ -130,7 +130,7 @@ public static function infolist(Infolist $infolist): Infolist
TextEntry::make('link')
->default(__('Unknown'))
->label(__('Link'))
->url(fn($state) => $state)
->url(fn ($state) => $state)
->openUrlInNewTab(),
TextEntry::make('tag')
->default(__('Unknown'))
Expand All @@ -152,7 +152,7 @@ public static function table(Table $table): Table
->label(__('Type'))
->sortable()
->badge()
->color(fn(WebhookEventType $state): string => match ($state) {
->color(fn (WebhookEventType $state): string => match ($state) {
WebhookEventType::DELIVERY => 'success',
WebhookEventType::CLICK => 'clicked',
WebhookEventType::OPEN => 'success',
Expand Down Expand Up @@ -197,4 +197,4 @@ public static function getPages(): array
'index' => ListEvents::route('/'),
];
}
}
}
16 changes: 8 additions & 8 deletions src/Resources/EventResource/Pages/ListEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace Vormkracht10\FilamentMails\Resources\EventResource\Pages;

use Filament\Resources\Components\Tab;
use Vormkracht10\Mails\Models\MailEvent;
use Filament\Resources\Pages\ListRecords;
use Illuminate\Database\Eloquent\Builder;
use Vormkracht10\Mails\Enums\WebhookEventType;
use Vormkracht10\FilamentMails\Resources\EventResource;
use Vormkracht10\Mails\Enums\WebhookEventType;
use Vormkracht10\Mails\Models\MailEvent;

class ListEvents extends ListRecords
{
Expand Down Expand Up @@ -35,31 +35,31 @@ public function getTabs(): array
->label(__('Delivery'))
->icon('heroicon-o-check-circle')
->badge(MailEvent::where('type', WebhookEventType::DELIVERY)->count())
->modifyQueryUsing(fn(Builder $query) => $query->where('type', WebhookEventType::DELIVERY)),
->modifyQueryUsing(fn (Builder $query) => $query->where('type', WebhookEventType::DELIVERY)),

'click' => Tab::make()
->label(__('Click'))
->icon('heroicon-o-cursor-arrow-rays')
->badge(MailEvent::where('type', WebhookEventType::CLICK)->count())
->modifyQueryUsing(fn(Builder $query) => $query->where('type', WebhookEventType::CLICK)),
->modifyQueryUsing(fn (Builder $query) => $query->where('type', WebhookEventType::CLICK)),

'open' => Tab::make()
->label(__('Open'))
->icon('heroicon-o-envelope-open')
->badge(MailEvent::where('type', WebhookEventType::OPEN)->count())
->modifyQueryUsing(fn(Builder $query) => $query->where('type', WebhookEventType::OPEN)),
->modifyQueryUsing(fn (Builder $query) => $query->where('type', WebhookEventType::OPEN)),

'bounce' => Tab::make()
->label(__('Bounce'))
->icon('heroicon-o-x-circle')
->badge(MailEvent::where('type', WebhookEventType::BOUNCE)->count())
->modifyQueryUsing(fn(Builder $query) => $query->where('type', WebhookEventType::BOUNCE)),
->modifyQueryUsing(fn (Builder $query) => $query->where('type', WebhookEventType::BOUNCE)),

'complaint' => Tab::make()
->label(__('Complaint'))
->icon('heroicon-o-exclamation-circle')
->badge(MailEvent::where('type', WebhookEventType::COMPLAINT)->count())
->modifyQueryUsing(fn(Builder $query) => $query->where('type', WebhookEventType::COMPLAINT)),
->modifyQueryUsing(fn (Builder $query) => $query->where('type', WebhookEventType::COMPLAINT)),
];
}
}
}
12 changes: 6 additions & 6 deletions src/Resources/MailResource/Pages/ListMails.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ public function getTabs(): array
->label(__('Sent'))
->icon('heroicon-o-paper-airplane')
->badge(Mail::sent()->count())
->modifyQueryUsing(fn(Builder $query) => $query->sent()),
->modifyQueryUsing(fn (Builder $query) => $query->sent()),
'delivered' => Tab::make()
->label(__('Delivered'))
->icon('heroicon-o-check-circle')
->badge(Mail::delivered()->count())
->modifyQueryUsing(fn(Builder $query) => $query->delivered()),
->modifyQueryUsing(fn (Builder $query) => $query->delivered()),
'bounced' => Tab::make()
->label(__('Bounced'))
->icon('heroicon-o-x-circle')
->badge(fn() => Mail::softBounced()->count() + Mail::hardBounced()->count())
->modifyQueryUsing(fn(Builder $query) => $query->where(function ($query) {
->badge(fn () => Mail::softBounced()->count() + Mail::hardBounced()->count())
->modifyQueryUsing(fn (Builder $query) => $query->where(function ($query) {
$query->softBounced()->orWhere(function ($query) {
$query->hardBounced();
});
Expand All @@ -53,7 +53,7 @@ public function getTabs(): array
->label(__('Unsent'))
->icon('heroicon-o-x-circle')
->badge(Mail::unsent()->count())
->modifyQueryUsing(fn(Builder $query) => $query->unsent()),
->modifyQueryUsing(fn (Builder $query) => $query->unsent()),
];
}

Expand All @@ -63,4 +63,4 @@ protected function getHeaderWidgets(): array
MailStatsWidget::class,
];
}
}
}
4 changes: 2 additions & 2 deletions src/Widgets/MailStatsWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MailStatsWidget 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 fa16cf8

Please sign in to comment.