40 lines
839 B
PHP
40 lines
839 B
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Notifications\Notification;
|
|
use NotificationChannels\Fcm\FcmChannel;
|
|
use NotificationChannels\Fcm\FcmMessage;
|
|
|
|
class SendNotification extends Notification
|
|
{
|
|
use Queueable;
|
|
|
|
private $title;
|
|
private $body;
|
|
private $data;
|
|
|
|
public function __construct($title, $body, $data)
|
|
{
|
|
$this->title = $title;
|
|
$this->body = $body;
|
|
$this->data = $data;
|
|
}
|
|
|
|
public function via($notifiable)
|
|
{
|
|
return [FcmChannel::class];
|
|
}
|
|
|
|
public function toFcm($notifiable)
|
|
{
|
|
return FcmMessage::create()
|
|
->setData($this->data) // Menggunakan $this->data
|
|
->setNotification([
|
|
'title' => $this->title,
|
|
'body' => $this->body,
|
|
]);
|
|
}
|
|
}
|