RoutineNotification.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace App\Notifications;
  3. use Illuminate\Bus\Queueable;
  4. use Illuminate\Contracts\Queue\ShouldQueue;
  5. use Illuminate\Notifications\Messages\BroadcastMessage;
  6. use Illuminate\Notifications\Notification;
  7. class RoutineNotification extends Notification implements ShouldQueue
  8. {
  9. use Queueable;
  10. /** @var array|mixed $seeLog */
  11. private $seeLog;
  12. public function __construct(array $seeLog)
  13. {
  14. $seeLog["no"] = $seeLog["id"];
  15. unset($seeLog["id"]);
  16. $this->seeLog = $seeLog;
  17. }
  18. /**
  19. * Get the notification's delivery channels.
  20. *
  21. * @param mixed $notifiable
  22. * @return array
  23. */
  24. public function via($notifiable):array
  25. {
  26. return ['broadcast'];
  27. }
  28. public function viaQueues():array
  29. {
  30. return [
  31. 'broadcast' => 'notification-broadcast',
  32. ];
  33. }
  34. public function broadcastType():string
  35. {
  36. return 'common';
  37. }
  38. public function toBroadcast($notifiable):BroadcastMessage
  39. {
  40. return new BroadcastMessage($this->seeLog);
  41. }
  42. }