HEX
Server: nginx/1.24.0
System: Linux DGT-WORDPRESS-VM-SERVER 6.14.0-1014-azure #14~24.04.1-Ubuntu SMP Fri Oct 3 20:52:11 UTC 2025 x86_64
User: ubuntu (1000)
PHP: 8.4.12
Disabled: NONE
Upload Files
File: /mnt/data/ghayatcom/ghayatcom-api/app/Notifications/HomeVisitDoctorNotify.php
<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use App\Channels\FcmChannel;
use App\Channels\Fcm;
use App\Channels\PusherChannel;
use App\Channels\Pusher;
use App\Helpers\GeneralHelper;

class HomeVisitDoctorNotify extends Notification implements ShouldQueue
{
    use Queueable;
    private $detail, $fcm_detail, $pusher;
    //$email_detail
    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct($detail)
    {
        $this->detail = $detail;
        // $this->email_detail = (isset($detail['mail'])) ? $detail['mail'] : [];
        $this->fcm_detail = (isset($detail['fcm'])) ? $detail['fcm'] : [];
        $this->pusher = (isset($detail['pusher'])) ? $detail['pusher'] : [];

        unset($this->detail['mail']);
        unset($this->detail['fcm']);
        unset($this->detail['pusher']);
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        if(!empty($this->email_detail)) {
            return ['database', FcmChannel::class,PusherChannel::class,'mail'];//'mail', FcmChannel::class, 'mail',
        } else {
            return ['database', FcmChannel::class,PusherChannel::class];
        }
    }

    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toMail($notifiable)
    {
        return [];
    }

    public function toFcm($notifiable)
    {
        if(!empty($this->fcm_detail)) {
            return (new Fcm())->triggerFcm($this->fcm_detail);
        }
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
            $this->detail
        ];
    }

    public function toPusher($notifiable)
    {
        return (new Pusher())->trigger($this->pusher);
    }
}