| 12345678910111213141516171819202122232425262728 |
- <?php
- namespace App\Services\Fcm;
- use Illuminate\Notifications\Notification;
- class FcmChannel
- {
- public function __construct(
- protected FcmService $fcm,
- ) {}
- public function send(object $notifiable, Notification $notification): void
- {
- if (!method_exists($notification, 'toFcm')) {
- return;
- }
- $data = $notification->toFcm($notifiable);
- $this->fcm->send(
- token: $data['to'],
- title: $data['notification']['title'] ?? '',
- body: $data['notification']['body'] ?? '',
- image: $data['notification']['image'] ?? null,
- );
- }
- }
|