Files
hr/app/Notifications/DisciplinaryReportCreatedNotification.php
2026-07-31 18:08:08 +05:00

57 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Notifications;
use App\Models\DisciplinaryReport;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class DisciplinaryReportCreatedNotification extends Notification implements ShouldQueue
{
use Queueable;
public function __construct(
public readonly DisciplinaryReport $report,
) {}
/**
* @return list<string>
*/
public function via(object $notifiable): array
{
return ['database', 'mail'];
}
public function toMail(object $notifiable): MailMessage
{
$employee = $this->report->employee;
return (new MailMessage)
->subject(__('notifications.disciplinary_report_created.subject'))
->line(__('notifications.disciplinary_report_created.line_created', ['name' => $employee->full_name]))
->line(__('notifications.disciplinary_report_created.title') . ': ' . $this->report->title)
->line(__('notifications.disciplinary_report_created.severity') . ': ' . $this->report->severity->label())
->line(__('notifications.disciplinary_report_created.date') . ': ' . $this->report->report_date->toDateString());
}
/**
* @return array<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [
'report_id' => $this->report->id,
'employee_id' => $this->report->employee_id,
'employee_name' => $this->report->employee->full_name,
'title' => $this->report->title,
'severity' => $this->report->severity->value,
'report_date' => $this->report->report_date->toDateString(),
'created_by' => $this->report->created_by,
];
}
}