File manager - Edit - /home/autoph/public_html/projects/app/Notifications/Wfh.php
Back
<?php namespace App\Notifications; use App\Models\EmployeeWfh; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; class Wfh extends Notification { use Queueable; private string $message; /** * Create a new notification instance. */ public function __construct(private EmployeeWfh $wfh) { $this->message = $this->generateMessage(); } /** * Get the notification's delivery channels. * * @return array<int, string> */ 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<string, mixed> */ 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.'; } } }
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0 |
proxy
|
phpinfo
|
Settings