File manager - Edit - /home/autoph/public_html/projects/app/Notifications/Travel.php
Back
<?php namespace App\Notifications; use App\Models\EmployeeOb; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; class Travel extends Notification { use Queueable; private string $message; /** * Create a new notification instance. */ public function __construct( private EmployeeOb $ob) { $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.travel', [ 'headerImageUrl' => asset('images/AUTOHUB25_BANNER.png'), // URL of the image 'msg' => $this->message, 'notifiable' => $notifiable, ]) ->subject('OB/Travel Notification'); } /** * Get the array representation of the notification. * * @return array<string, mixed> */ public function toArray(object $notifiable): array { $title = null; if($this->ob->validated == 1){ $title = "Your OB application has been received and validated by HR"; }else if($this->ob->validated == 99){ $title = "Your OB applicationn has been denied by HR"; }else if($this->ob->status == 2){ $title = "Your OB application has been approved"; }else if($this->ob->status == 99){ $title = "Your OB application has been denied "; }else{ $this->ob->employee->firstname . ' ' . $this->ob->employee->lastname." Submitted OB Application"; } return [ 'leave_id' => $this->ob->id, 'status' => $this->ob->status, 'approved_at' => $this->ob->approved_at, 'message' => $this->message, 'title' => $title, 'url' => 'attendance/official-business', 'created_by' => $this->ob->employee_id ]; } private function generateMessage(): string { $fullname = $this->ob->employee->firstname.' '.$this->ob->employee->lastname; $date = $this->ob->date; $from_time = $this->ob->from_time; $to_time = $this->ob->to_time; switch ($this->ob->status) { case 1: case 0: return $fullname.' filed ob application dated "'.$date. '" time from "'.$from_time.'" to "'.$to_time.'" for your validation.'; case 2: if($this->ob->validated == 1){ return 'Your ob application dated "'.$date. '" time from "'.$from_time.'" to "'.$to_time.'" has been received and validated by HR.'; }else if($this->ob->validated == 99){ return 'Your ob application dated "'.$date. '" time from "'.$from_time.'" to "'.$to_time.'" has been denied by HR.'; }else{ return 'Your ob application dated "'.$date. '" time from "'.$from_time.'" to "'.$to_time.'" has been approved.'; } case 99: return 'Your ob application dated "'.$date. '" time from "'.$from_time.'" to "'.$to_time.'" has been denied.'; default: return 'Unknown status.'; } } }
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0 |
proxy
|
phpinfo
|
Settings