generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
325 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
return [ | ||
'navigation.group' => 'Logs', | ||
|
||
'navigation.maillog.label' => 'Mail Log', | ||
'navigation.maillog.plural-label' => 'Mail Logs', | ||
|
||
'table.heading' => 'Mail Logs', | ||
|
||
'column.status' => 'Status', | ||
'column.date' => 'Date', | ||
'column.subject' => 'Subject', | ||
'column.to' => 'To', | ||
'column.from' => 'From', | ||
'column.cc' => 'CC', | ||
'column.bcc' => 'BCC', | ||
'column.message_id' => 'Message ID', | ||
'column.delivered' => 'Delivered', | ||
'column.opened' => 'Opened', | ||
'column.bounced' => 'Bounced', | ||
'column.complaint' => 'Complaint', | ||
'column.body' => 'Body', | ||
'column.headers' => 'Headers', | ||
'column.attachments' => 'Attachments', | ||
'column.data' => 'Log', | ||
'column.created_at' => 'Created At', | ||
'column.updated_at' => 'Updated At', | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Tapp\FilamentMailLog; | ||
|
||
use Filament\Contracts\Plugin; | ||
use Filament\Panel; | ||
|
||
class FilamentMailLogPlugin implements Plugin | ||
{ | ||
public static function make(): static | ||
{ | ||
return app(static::class); | ||
} | ||
|
||
public function getId(): string | ||
{ | ||
return 'filament-maillog'; | ||
} | ||
|
||
public function register(Panel $panel): void | ||
{ | ||
$panel | ||
->resources( | ||
config('filament-maillog.resources') | ||
); | ||
} | ||
|
||
public function boot(Panel $panel): void | ||
{ | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
<?php | ||
|
||
namespace Tapp\FilamentMailLog\Resources; | ||
|
||
use Tapp\FilamentMailLog\Resources\MailLogResource\Pages; | ||
use Tapp\FilamentMailLog\Models\MailLog; | ||
use Filament\Forms; | ||
use Filament\Infolists; | ||
use Filament\Infolists\Infolist; | ||
use Filament\Resources\Resource; | ||
use Filament\Tables\Table; | ||
use Filament\Tables; | ||
use Filament\Tables\Filters\Filter; | ||
use Filament\Tables\Filters\SelectFilter; | ||
use Illuminate\Database\Eloquent\Builder; | ||
|
||
class MailLogResource extends Resource | ||
{ | ||
protected static ?string $model = MailLog::class; | ||
|
||
public static function shouldRegisterNavigation(): bool | ||
{ | ||
return config('filament-maillog.navigation.maillog.register', true); | ||
} | ||
|
||
public static function getNavigationIcon(): string | ||
{ | ||
return config('filament-maillog.navigation.maillog.icon'); | ||
} | ||
|
||
public static function getNavigationSort(): ?int | ||
{ | ||
return config('filament-maillog.navigation.maillog.sort'); | ||
} | ||
|
||
public static function getNavigationGroup(): ?string | ||
{ | ||
return __('filament-maillog::filament-maillog.navigation.group'); | ||
} | ||
|
||
public static function getLabel(): string | ||
{ | ||
return __('filament-maillog::filament-maillog.navigation.maillog.label'); | ||
} | ||
|
||
public static function getPluralLabel(): string | ||
{ | ||
return __('filament-maillog::filament-maillog.navigation.maillog.plural-label'); | ||
} | ||
|
||
public static function infolist(Infolist $infolist): Infolist | ||
{ | ||
return $infolist | ||
->schema([ | ||
Infolists\Components\TextEntry::make('message_id') | ||
->label(trans('filament-maillog::filament-maillog.column.message_id')), | ||
Infolists\Components\TextEntry::make('subject') | ||
->label(trans('filament-maillog::filament-maillog.column.subject')), | ||
Infolists\Components\TextEntry::make('date') | ||
->label(trans('filament-maillog::filament-maillog.column.date')) | ||
->datetime(), | ||
Infolists\Components\TextEntry::make('to') | ||
->label(trans('filament-maillog::filament-maillog.column.to')), | ||
Infolists\Components\TextEntry::make('from') | ||
->label(trans('filament-maillog::filament-maillog.column.from')), | ||
Infolists\Components\TextEntry::make('cc') | ||
->label(trans('filament-maillog::filament-maillog.column.cc')), | ||
Infolists\Components\TextEntry::make('bcc') | ||
->label(trans('filament-maillog::filament-maillog.column.bcc')), | ||
Infolists\Components\TextEntry::make('status') | ||
->label(trans('filament-maillog::filament-maillog.column.status')) | ||
->badge(), | ||
Infolists\Components\TextEntry::make('delivered') | ||
->label(trans('filament-maillog::filament-maillog.column.delivered')), | ||
Infolists\Components\TextEntry::make('opened') | ||
->label(trans('filament-maillog::filament-maillog.column.opened')), | ||
Infolists\Components\TextEntry::make('bounced') | ||
->label(trans('filament-maillog::filament-maillog.column.bounced')), | ||
Infolists\Components\TextEntry::make('complaint') | ||
->label(trans('filament-maillog::filament-maillog.column.complaint')), | ||
Infolists\Components\TextEntry::make('body') | ||
->label(trans('filament-maillog::filament-maillog.column.body')) | ||
->html() | ||
->columnSpanFull(), | ||
Infolists\Components\TextEntry::make('headers') | ||
->label(trans('filament-maillog::filament-maillog.column.headers')) | ||
->columnSpanFull(), | ||
Infolists\Components\TextEntry::make('attachments') | ||
->label(trans('filament-maillog::filament-maillog.column.attachments')) | ||
->columnSpanFull(), | ||
Infolists\Components\Section::make('Log') | ||
->label(trans('filament-maillog::filament-maillog.column.data')) | ||
->icon('heroicon-m-list-bullet') | ||
->schema([ | ||
Infolists\Components\TextEntry::make('data') | ||
->label(false), | ||
]) | ||
->columnSpanFull(), | ||
]); | ||
} | ||
|
||
public static function table(Table $table): Table | ||
{ | ||
return $table | ||
->columns([ | ||
Tables\Columns\TextColumn::make('status') | ||
->label(trans('filament-maillog::filament-maillog.column.status')) | ||
->sortable(), | ||
Tables\Columns\TextColumn::make('date') | ||
->label(trans('filament-maillog::filament-maillog.column.date')) | ||
->dateTime() | ||
->sortable(), | ||
Tables\Columns\TextColumn::make('subject') | ||
->label(trans('filament-maillog::filament-maillog.column.subject')) | ||
->limit(25) | ||
->tooltip(function (Tables\Columns\TextColumn $column): ?string { | ||
$state = $column->getState(); | ||
|
||
if (strlen($state) <= $column->getCharacterLimit()) { | ||
return null; | ||
} | ||
|
||
// Only render the tooltip if the column content exceeds the length limit. | ||
return $state; | ||
}) | ||
->searchable() | ||
->sortable(), | ||
Tables\Columns\TextColumn::make('to') | ||
->label(trans('filament-maillog::filament-maillog.column.to')) | ||
->searchable() | ||
->sortable(), | ||
Tables\Columns\TextColumn::make('from') | ||
->label(trans('filament-maillog::filament-maillog.column.from')) | ||
->sortable(), | ||
Tables\Columns\TextColumn::make('created_at') | ||
->label(trans('filament-maillog::filament-maillog.column.created_at')) | ||
->dateTime() | ||
->sortable() | ||
->toggleable(isToggledHiddenByDefault: true), | ||
Tables\Columns\TextColumn::make('updated_at') | ||
->label(trans('filament-maillog::filament-maillog.column.updated_at')) | ||
->dateTime() | ||
->sortable() | ||
->toggleable(isToggledHiddenByDefault: true), | ||
]) | ||
->filters([ | ||
SelectFilter::make('status') | ||
->options(MailLog::distinct('status')->pluck('status', 'status')->filter()->toArray()), | ||
Filter::make('created_at') | ||
->form([ | ||
Forms\Components\DatePicker::make('created_from'), | ||
Forms\Components\DatePicker::make('created_until'), | ||
]) | ||
->query(function (Builder $query, array $data): Builder { | ||
return $query | ||
->when( | ||
$data['created_from'], | ||
fn (Builder $query, $date): Builder => $query->whereDate('created_at', '>=', $date), | ||
) | ||
->when( | ||
$data['created_until'], | ||
fn (Builder $query, $date): Builder => $query->whereDate('created_at', '<=', $date), | ||
); | ||
}), | ||
]) | ||
->actions([ | ||
Tables\Actions\ViewAction::make(), | ||
]); | ||
} | ||
|
||
public static function getRelations(): array | ||
{ | ||
return [ | ||
// | ||
]; | ||
} | ||
|
||
public static function getPages(): array | ||
{ | ||
return [ | ||
'index' => Pages\ListMailLogs::route('/'), | ||
//'view' => Pages\ViewMailLog::route('/{record}'), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Tapp\FilamentMailLog\Resources\MailLogResource\Pages; | ||
|
||
use Tapp\FilamentMailLog\Resources\MailLogResource; | ||
use Filament\Resources\Pages\ListRecords; | ||
|
||
class ListMailLogs extends ListRecords | ||
{ | ||
protected static string $resource = MailLogResource::class; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Tapp\FilamentMailLog\Resources\MailLogResource\Pages; | ||
|
||
use Filament\Resources\Pages\ViewRecord; | ||
use Tapp\FilamentMailLog\Resources\MailLogResource; | ||
|
||
class ViewMailLog extends ViewRecord | ||
{ | ||
protected static string $resource = MailLogResource::class; | ||
} |