Skip to content

Commit

Permalink
Fix email
Browse files Browse the repository at this point in the history
  • Loading branch information
alexPopaCode4 committed Dec 2, 2024
1 parent 5f43351 commit f9eb48c
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ protected function handleRecordCreation(array $data): Model
{
if ($user = User::query()->where('email', $data['email'])->first()) {
$this->associateRecordWithTenant($user, Filament::getTenant());
$user->sendWelcomeNotification();
$user->initializeStatus();
$user->sendWelcomeNotificationInAnotherTenant();

return $user;
}
Expand Down
6 changes: 6 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Concerns\HasPermissions;
use App\Concerns\HasUlid;
use App\Concerns\MustSetInitialPassword;
use App\Notifications\Organizations\WelcomeNotificationInAnotherTenant;
use Filament\Facades\Filament;
use Filament\Models\Contracts\FilamentUser;
use Filament\Models\Contracts\HasAvatar;
Expand Down Expand Up @@ -281,4 +282,9 @@ public function initializeStatus(): void
'organization_id' => Filament::getTenant()->id,
]);
}

public function sendWelcomeNotificationInAnotherTenant(): void
{
$this->notify(new WelcomeNotificationInAnotherTenant);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

declare(strict_types=1);

namespace App\Notifications\Organizations;

use Filament\Facades\Filament;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\HtmlString;
use Vite;

class WelcomeNotificationInAnotherTenant extends Notification
{
use Queueable;

public string $route = 'filament.organization.pages.dashboard';

/**
* Get the notification's delivery channels.
*
* @return array<int, string>
*/
public function via(object $notifiable): array
{
return ['mail'];
}

/**
* Get the mail representation of the notification.
*/
public function toMail(object $notifiable): MailMessage
{
// TODO: change line msg
return (new MailMessage)
->subject(__('email.organization.welcome.subject'))
->line('![Logo](' . Vite::asset('resources/svg/logo.svg') . ')')
->greeting(__('email.organization.welcome.greeting', ['name' => $notifiable->first_name]))
->line(
__('email.organization.welcome.intro_line_1', [
'institution_name' => Filament::getTenant()?->institution->name ?? '',
'center_name' => Filament::getTenant()?->name ?? '',
])
)
->line(__('email.organization.welcome.intro_line_2'))
->line(__('email.organization.welcome.intro_line_3'))
->action(
__('email.organization.welcome.accept_invitation'),
URL::signedRoute($this->route, ['tenant' => Filament::getTenant()])
)
->line(__('email.organization.welcome.intro_line_4'))
->line(new HtmlString(__('email.organization.welcome.intro_line_5')))
->salutation(__('email.salutation'));
}
}

0 comments on commit f9eb48c

Please sign in to comment.