complete story 2.3 with qa test

This commit is contained in:
Naser Mansour
2025-12-26 15:55:42 +02:00
parent b9009ca1df
commit b207be196e
13 changed files with 1185 additions and 36 deletions
@@ -0,0 +1,59 @@
<?php
namespace App\Notifications;
use App\Enums\UserType;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class AccountTypeChangedNotification extends Notification implements ShouldQueue
{
use Queueable;
public function __construct(
public UserType $newUserType
) {}
/**
* 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
{
$locale = $notifiable->preferred_language ?? 'ar';
$typeName = $this->newUserType === UserType::Company
? __('clients.company', [], $locale)
: __('clients.individual', [], $locale);
return (new MailMessage)
->subject(__('emails.account_type_changed_subject', [], $locale))
->view('emails.account-type-changed', [
'user' => $notifiable,
'newType' => $typeName,
'locale' => $locale,
]);
}
/**
* Get the array representation of the notification.
*
* @return array<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [
'new_user_type' => $this->newUserType->value,
];
}
}