FireBaseNotification.php 932 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\Notifications;
  3. use Illuminate\Bus\Queueable;
  4. use Illuminate\Contracts\Queue\ShouldQueue;
  5. use Illuminate\Notifications\Messages\MailMessage;
  6. use Illuminate\Notifications\Notification;
  7. class FireBaseNotification extends Notification
  8. {
  9. use Queueable;
  10. /**
  11. * Create a new notification instance.
  12. */
  13. public function __construct()
  14. {
  15. //
  16. }
  17. /**
  18. * Get the notification's delivery channels.
  19. *
  20. * @return array<int, string>
  21. */
  22. public function via(object $notifiable): array
  23. {
  24. return ['fcm'];
  25. }
  26. public function toFcm(object $notifiable): array
  27. {
  28. return [
  29. 'to' => $notifiable->token_fcm,
  30. 'notification' => [
  31. 'title' => 'Notification Title',
  32. 'body' => 'Notification Body',
  33. 'image' => '', // Optional image URL
  34. ],
  35. ];
  36. }
  37. }