libra/app/Mail/WelcomeEmail.php

68 lines
1.6 KiB
PHP

<?php
namespace App\Mail;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class WelcomeEmail extends Mailable implements ShouldQueue
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*/
public function __construct(
public User $user,
public string $password
) {
$this->locale = $user->preferred_language ?? 'ar';
}
/**
* Get the message envelope.
*/
public function envelope(): Envelope
{
$locale = $this->user->preferred_language ?? 'ar';
return new Envelope(
subject: $locale === 'en'
? 'Welcome to Libra Law Firm'
: 'مرحباً بك في مكتب ليبرا للمحاماة',
);
}
/**
* Get the message content definition.
*/
public function content(): Content
{
$locale = $this->user->preferred_language ?? 'ar';
return new Content(
markdown: 'emails.welcome.'.$locale,
with: [
'user' => $this->user,
'password' => $this->password,
'loginUrl' => route('login'),
],
);
}
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
*/
public function attachments(): array
{
return [];
}
}