Skip to content

Commit

Permalink
adds the persist_team_id config
Browse files Browse the repository at this point in the history
  • Loading branch information
moedayraki committed Nov 28, 2024
1 parent 57f8095 commit 4c289c6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
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;
}
}

0 comments on commit 4c289c6

Please sign in to comment.