complete story 8.2 with qa tests

This commit is contained in:
Naser Mansour
2025-12-29 00:58:36 +02:00
parent 911624901f
commit d1016c89f8
7 changed files with 432 additions and 84 deletions
+67
View File
@@ -0,0 +1,67 @@
<?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 [];
}
}
@@ -2,9 +2,11 @@
namespace App\Notifications;
use App\Mail\WelcomeEmail;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Mail\Mailable;
use Illuminate\Notifications\Notification;
class WelcomeAccountNotification extends Notification implements ShouldQueue
@@ -29,17 +31,11 @@ class WelcomeAccountNotification extends Notification implements ShouldQueue
/**
* Get the mail representation of the notification.
*/
public function toMail(object $notifiable): MailMessage
public function toMail(object $notifiable): Mailable
{
$locale = $notifiable->preferred_language ?? 'ar';
return (new MailMessage)
->subject(__('emails.welcome_subject', [], $locale))
->view('emails.welcome', [
'user' => $notifiable,
'password' => $this->password,
'locale' => $locale,
]);
/** @var User $notifiable */
return (new WelcomeEmail($notifiable, $this->password))
->to($notifiable->email);
}
/**