base commit
This commit is contained in:
56
app/Notifications/DisciplinaryReportCreatedNotification.php
Normal file
56
app/Notifications/DisciplinaryReportCreatedNotification.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?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('New Disciplinary Report Created')
|
||||
->line("A new disciplinary report has been created for {$employee->full_name}.")
|
||||
->line("Title: {$this->report->title}")
|
||||
->line("Severity: {$this->report->severity->label()}")
|
||||
->line("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,
|
||||
];
|
||||
}
|
||||
}
|
||||
50
app/Notifications/EmployeeTerminatedNotification.php
Normal file
50
app/Notifications/EmployeeTerminatedNotification.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\Employee;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class EmployeeTerminatedNotification extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(
|
||||
public readonly Employee $employee,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return ['database', 'mail'];
|
||||
}
|
||||
|
||||
public function toMail(object $notifiable): MailMessage
|
||||
{
|
||||
return (new MailMessage)
|
||||
->subject('Employee Terminated')
|
||||
->line("{$this->employee->full_name} ({$this->employee->employee_number}) has been terminated.")
|
||||
->line("Termination date: {$this->employee->termination_date?->toDateString()}");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(object $notifiable): array
|
||||
{
|
||||
return [
|
||||
'employee_id' => $this->employee->id,
|
||||
'employee_number' => $this->employee->employee_number,
|
||||
'full_name' => $this->employee->full_name,
|
||||
'termination_date' => $this->employee->termination_date?->toDateString(),
|
||||
'department_id' => $this->employee->department_id,
|
||||
];
|
||||
}
|
||||
}
|
||||
58
app/Notifications/VacationApprovedNotification.php
Normal file
58
app/Notifications/VacationApprovedNotification.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\Vacation;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class VacationApprovedNotification extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(
|
||||
public readonly Vacation $vacation,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return ['database', 'mail'];
|
||||
}
|
||||
|
||||
public function toMail(object $notifiable): MailMessage
|
||||
{
|
||||
$employee = $this->vacation->employee;
|
||||
|
||||
return (new MailMessage)
|
||||
->subject('Vacation Request Approved')
|
||||
->line("The vacation request for {$employee->full_name} has been approved.")
|
||||
->line("Type: {$this->vacation->type->label()}")
|
||||
->line("Dates: {$this->vacation->start_date->toDateString()} to {$this->vacation->end_date->toDateString()}")
|
||||
->line("Days: {$this->vacation->days}");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(object $notifiable): array
|
||||
{
|
||||
return [
|
||||
'vacation_id' => $this->vacation->id,
|
||||
'employee_id' => $this->vacation->employee_id,
|
||||
'employee_name' => $this->vacation->employee->full_name,
|
||||
'type' => $this->vacation->type->value,
|
||||
'start_date' => $this->vacation->start_date->toDateString(),
|
||||
'end_date' => $this->vacation->end_date->toDateString(),
|
||||
'days' => $this->vacation->days,
|
||||
'approved_by' => $this->vacation->approved_by,
|
||||
'approved_at' => $this->vacation->approved_at?->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
||||
57
app/Notifications/VacationSubmittedNotification.php
Normal file
57
app/Notifications/VacationSubmittedNotification.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\Vacation;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class VacationSubmittedNotification extends Notification implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(
|
||||
public readonly Vacation $vacation,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
public function via(object $notifiable): array
|
||||
{
|
||||
return ['database', 'mail'];
|
||||
}
|
||||
|
||||
public function toMail(object $notifiable): MailMessage
|
||||
{
|
||||
$employee = $this->vacation->employee;
|
||||
|
||||
return (new MailMessage)
|
||||
->subject('New Vacation Request Submitted')
|
||||
->line("A new vacation request has been submitted for {$employee->full_name}.")
|
||||
->line("Type: {$this->vacation->type->label()}")
|
||||
->line("Dates: {$this->vacation->start_date->toDateString()} to {$this->vacation->end_date->toDateString()}")
|
||||
->line("Days: {$this->vacation->days}");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(object $notifiable): array
|
||||
{
|
||||
return [
|
||||
'vacation_id' => $this->vacation->id,
|
||||
'employee_id' => $this->vacation->employee_id,
|
||||
'employee_name' => $this->vacation->employee->full_name,
|
||||
'type' => $this->vacation->type->value,
|
||||
'start_date' => $this->vacation->start_date->toDateString(),
|
||||
'end_date' => $this->vacation->end_date->toDateString(),
|
||||
'days' => $this->vacation->days,
|
||||
'status' => $this->vacation->status->value,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user