Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gives the option to always save 'null' to the 'team_id' column #83

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ return [
//Use this option for customize tenant model class
//'tenant_model' => \App\Models\Team::class,

'persist_team_id' => true,

];
```

Expand Down
2 changes: 2 additions & 0 deletions config/filament-email.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@
//Use this option for customize tenant model class
//'tenant_model' => \App\Models\Team::class,

'persist_team_id' => true,

];
13 changes: 11 additions & 2 deletions src/Listeners/FilamentEmailLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function handle(object $event): void
$storeAttachments = config('filament-email.store_attachments', true);

$model = config('filament-email.resource.model') ?? Email::class;

$attachments = [];
$savePath = 'filament-email-log'.DIRECTORY_SEPARATOR.date('YmdHis').'_'.Str::random(5).DIRECTORY_SEPARATOR;

Expand All @@ -57,7 +57,7 @@ public function handle(object $event): void
$savePathRaw = null;
}
$model::create([
'team_id' => Filament::getTenant()?->id ?? null,
'team_id' => $this->getTeamId(),
'from' => $this->recipientsToString($email->getFrom()),
'to' => $this->recipientsToString($email->getTo()),
'cc' => $this->recipientsToString($email->getCc()),
Expand All @@ -81,4 +81,13 @@ private function recipientsToString(array $recipients): string
}, $recipients)
);
}

private function getTeamId(): ?int
{
if(config('filament-email.persist_team_id')){
return Filament::getTenant()?->id ?? null;
}

return null;
}
}