File manager - Edit - /home/autoph/public_html/projects/app/Notifications/Mrf.php
Back
<?php namespace App\Notifications; use App\Models\Mrf as ModelsMrf; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; use Illuminate\Support\Facades\Crypt; class Mrf extends Notification { use Queueable; private string $message; /** * Create a new notification instance. */ public function __construct( private ModelsMrf $mrf ) { $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 { $notifiable->url = 'recruitment/mrf'; $notifiable->encrypted_id = Crypt::encrypt($notifiable->id); // dd($notifiable); return (new MailMessage) ->view('emails.mrf', [ 'headerImageUrl' => asset('images/AUTOHUB25_BANNER.png'), // URL of the image 'msg' => $this->message, 'notifiable' => $notifiable, ]) ->subject('MRF Request'); } /** * Get the array representation of the notification. * * @return array<string, mixed> */ public function toArray(object $notifiable): array { return [ 'mrf_id' => $this->mrf->id, 'status' => $this->mrf->status, 'approved_at' => $this->mrf->approved_at, 'message' => $this->message, 'title' => ($this->mrf->status == 3) ? "Your MRF request has been approved" : (($this->mrf->status == 99) ? "Your MRF request has been denied" : $this->mrf->employee->firstname . ' ' . $this->mrf->employee->lastname." Submitted MRF Application" ), 'url' => 'recruitment/mrf', 'created_by' => $this->mrf->employee_id ]; } private function generateMessage(): string { $fullname = $this->mrf->employee->firstname . ' ' . $this->mrf->employee->lastname; switch ($this->mrf->status) { case 0: case 1: return $fullname.' submitted MRF for your checking'; case 3: return 'Your requested MRF has been approved'; case 2: return "MRF has been submitted for your checking."; case 99: return "Your MRF request has been denied."; default: return 'Unknown status.'; } } }
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0 |
proxy
|
phpinfo
|
Settings