File manager - Edit - /home/autoph/public_html/projects/app/Notifications/Undertime.php
Back
<?php namespace App\Notifications; use App\Models\EmployeeUndertime; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; class Undertime extends Notification { use Queueable; private string $message; /** * Create a new notification instance. */ public function __construct(private EmployeeUndertime $undertime) { $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.undertime', [ 'headerImageUrl' => asset('images/AUTOHUB25_BANNER.png'), // URL of the image 'msg' => $this->message, 'notifiable' => $notifiable, ]) ->subject('Undertime Notification'); } /** * Get the array representation of the notification. * * @return array<string, mixed> */ public function toArray(object $notifiable): array { return [ 'undertime_id' => $this->undertime->id, 'status' => $this->undertime->status, 'approved_at' => $this->undertime->approved_at, 'message' => $this->message, 'title' => ($this->undertime->status == 2) ? "Your undertime application has been approved" : (($this->undertime->status == 99) ? "Your undertime application has been denied" : $this->undertime->employee->firstname . ' ' . $this->undertime->employee->lastname." Submitted Undertime Application" ), 'url' => 'attendance/undertime', 'created_by' => $this->undertime->employee_id ]; } private function generateMessage(): string { $fullname = $this->undertime->employee->firstname.' '.$this->undertime->employee->lastname; $date = $this->undertime->date; $from_time = $this->undertime->from_time; $to_time = $this->undertime->to_time; switch ($this->undertime->status) { case 1: case 0: return $fullname.' filed undertime application dated "'.$date. '" time from "'.$from_time.'" to "'.$to_time.'" for your validation.'; case 2: return 'Your undertime application dated "'.$date. '" time from "'.$from_time.'" to "'.$to_time.'" has been approved.'; case 99: return 'Your undertime 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