home/autoph/public_html/projects/app/Notifications/Wfh.php 0000644 00000006627 15030253500 0017761 0 ustar 00 message = $this->generateMessage();
}
/**
* Get the notification's delivery channels.
*
* @return array
*/
public function via(object $notifiable): array
{
return ['mail', 'database'];
}
/**
* Get the mail representation of the notification.
*/
public function toMail(object $notifiable): MailMessage
{
return (new MailMessage)
->view('emails.wfh', [
'headerImageUrl' => asset('images/AUTOHUB25_BANNER.png'), // URL of the image
'msg' => $this->message,
'notifiable' => $notifiable,
])
->subject('wfh Notification');
}
/**
* Get the array representation of the notification.
*
* @return array
*/
public function toArray(object $notifiable): array
{
$title = null;
if($this->wfh->validated == 1){
$title = "Your wfh application has been received and validated by HR";
}else if($this->wfh->validated == 99){
$title = "Your wfh application has been denied by HR";
}else if($this->wfh->status == 2){
$title = "Your wfh application has been approved";
}else if($this->wfh->status == 99){
$title = "Your wfh application has been denied ";
}else{
$title = $this->wfh->employee->firstname . ' ' . $this->wfh->employee->lastname." Submitted wfh Application";
}
return [
'wfh_id' => $this->wfh->id,
'status' => $this->wfh->status,
'approved_at' => $this->wfh->approved_at,
'message' => $this->message,
'title' => $title,
'url' => ($this->wfh->status == 2) ?
'attendance/wfh' : 'attendance/wfh-approval',
'created_by' => $this->wfh->employee_id
];
}
private function generateMessage(): string
{
$fullname = $this->wfh->employee->firstname.' '.$this->wfh->employee->lastname;
$date = $this->wfh->date;
$hours = $this->wfh->hours;
switch ($this->wfh->status) {
case 1:
case 0:
return $fullname.' filed wfh application dated "'.$date. '" for '.$hours.' Hours for your validation.';
case 2:
if($this->wfh->validated == 1){
return 'Your wfh application dated "'.$date. '" for '.$hours.' Hours has been received and validated by HR.';
}else if($this->wfh->validated == 99){
return 'Your wfh application dated "'.$date. '" for '.$hours.' Hours has been denied by HR.';
}else{
return 'Your wfh application dated "'.$date. '" for '.$hours.' Hours has been approved.';
}
case 99:
return 'Your wfh application dated "'.$date. '" for '.$hours.' Hours has been denied.';
default:
return 'Unknown status.';
}
}
}