You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.1 KiB

  1. <?php
  2. namespace App\Notifications;
  3. use Illuminate\Bus\Queueable;
  4. use Illuminate\Notifications\Notification;
  5. class DBNotification extends Notification
  6. {
  7. use Queueable;
  8. public $message;
  9. /**
  10. * Create a new notification instance.
  11. *
  12. * @return void
  13. */
  14. public function __construct($message)
  15. {
  16. $this->message = $message;
  17. }
  18. /**
  19. * Get the notification's delivery channels.
  20. *
  21. * @param mixed $notifiable
  22. * @return array
  23. */
  24. public function via($notifiable)
  25. {
  26. return ['database'];
  27. }
  28. /**
  29. * Get the array representation of the notification.
  30. *
  31. * @param mixed $notifiable
  32. * @return array
  33. */
  34. public function toArray($notifiable)
  35. {
  36. return [
  37. 'data' => $this->message['body'],
  38. ];
  39. }
  40. /**
  41. * Get the array for optional database field that added to original table.
  42. * @param $notifiable
  43. * @return array
  44. */
  45. public function toDatabaseOptional($notifiable)
  46. {
  47. return [
  48. 'business_id' => $this->message['business_id'] ?? null
  49. ];
  50. }
  51. }