Courses

Laravel 12 Multi-Tenancy: All You Need To Know

Sending Invitation Email and Accept Route

You're reading a FREE PREVIEW of a PREMIUM course.
Summary of this lesson:
- Creating a Notification class
- Setting up email template with tenant information
- Implementing temporary signed URLs for invitations
- Adding accept invitation route and token validation

Next, we need to send the invitation via email.


Laravel Notification Class

Let's create an Laravel Notification class for invitations.

php artisan make:notification SendInvitationNotification

The SendInvitationNotification class will accept the Notification Model as a parameter. Then, we will be able to add the tenant's name to the email.

app/Http/Notifications/:

use App\Models\Invitation;
 
class SendInvitationNotification extends Notification
{
use Queueable;
 
public function __construct(private readonly Invitation $invitation)
{
//
}
 
public function via(object $notifiable): array
{
return ['mail'];
}
 
public function toMail(object $notifiable): MailMessage
{
return (new MailMessage)
->line("You are invited to the team {$this->invitation->tenant->name}")
->action('Notification Action', url('/'))
->line('Thank you for using our application!');
}
 
// ...
}

To call $this->invitation->tenant, we need to add one more thing: we haven't yet added the tenant...

The full lesson is only for Premium Members.
Want to access all 22 lessons of this course? (88 min read)

You also get:

  • 76 courses
  • Premium tutorials
  • Access to repositories
  • Private Discord