File manager - Edit - /home/autoph/public_html/projects/app/Notifications/OffsetAvailment.php
Back
<?php namespace App\Notifications; use App\Models\EmployeeOffset; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; class OffsetAvailment extends Notification { use Queueable; private string $message; /** * Create a new notification instance. */ public function __construct( private EmployeeOffset $offsetAvailment) { $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.offset_availment', [ 'headerImageUrl' => asset('images/AUTOHUB25_BANNER.png'), // URL of the image 'msg' => $this->message, 'notifiable' => $notifiable, ]) ->subject('Offset Availment Notification'); } /** * Get the array representation of the notification. * * @return array<string, mixed> */ public function toArray(object $notifiable): array { return [ 'offset_availment_id' => $this->offsetAvailment->id, 'status' => $this->offsetAvailment->status, 'approved_at' => $this->offsetAvailment->approved_at, 'message' => $this->message, 'title' => ($this->offsetAvailment->status == 2) ? "Your offset availment application has been approved" : (($this->offsetAvailment->status == 99) ? "Your offset availment application has been denied" : $this->offsetAvailment->employee->firstname . ' ' . $this->offsetAvailment->employee->lastname." Submitted Offset Availment Application" ), 'url' => 'attendance/offset-approval', 'created_by' => $this->offsetAvailment->employee_id ]; } private function generateMessage(): string { $fullname = $this->offsetAvailment->employee->firstname.' '.$this->offsetAvailment->employee->lastname; $date = $this->offsetAvailment->date; $hours = $this->offsetAvailment->hours; switch ($this->offsetAvailment->status) { case 1: case 0: return $fullname.' filed offset availment application dated "'.$date. '" for "'.$hours.'".'; case 2: return 'Your offset availment dated "'.$date. '" for "'.$hours.'".'; case 99: return 'Your offset availment application dated "'.$date. '" for "'.$hours.'".'; default: return 'Unknown status.'; } } }
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0 |
proxy
|
phpinfo
|
Settings