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.

67 lines
1.4 KiB

  1. <?php
  2. namespace App\Notifications;
  3. use App\Channels\Messages\SmsMessage;
  4. use Illuminate\Bus\Queueable;
  5. use Illuminate\Contracts\Queue\ShouldQueue;
  6. use Illuminate\Notifications\Messages\MailMessage;
  7. use Illuminate\Notifications\Notification;
  8. class SmsNotification extends Notification
  9. {
  10. use Queueable;
  11. public $message;
  12. /**
  13. * Show type of sms notification.
  14. * [ultraFastSend or sendVerification ]
  15. *
  16. * @var mixed|string
  17. */
  18. public $type;
  19. /**
  20. * Create a new notification instance.
  21. *
  22. * @return void
  23. */
  24. public function __construct($message, $type = 'sendVerification')
  25. {
  26. $this->message = $message;
  27. $this->type = $type;
  28. }
  29. /**
  30. * Get the notification's delivery channels.
  31. *
  32. * @param mixed $notifiable
  33. * @return array
  34. */
  35. public function via($notifiable)
  36. {
  37. return ['sms'];
  38. }
  39. /**
  40. * Get the array representation of the notification.
  41. *
  42. * @param mixed $notifiable
  43. * @return array
  44. */
  45. public function toSms($notifiable)
  46. {
  47. return (new SmsMessage())
  48. ->params($this->message['params'] ?? null)
  49. ->templateId($this->message['template_id'] ?? null)
  50. ->verificationCode($this->message['verification_code'] ?? null);
  51. }
  52. public function getType()
  53. {
  54. return $this->type;
  55. }
  56. }