File: /mnt/data/ghayatcom/ghayatcom-api/app/Notifications/AppointmentDailyReminderNotify.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 AppointmentDailyReminderNotify 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);
}
}