Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Notifications;
  4.  
  5. use Illuminate\Bus\Queueable;
  6. use Illuminate\Notifications\AnonymousNotifiable;
  7. use Illuminate\Notifications\Notification;
  8. use Illuminate\Contracts\Queue\ShouldQueue;
  9. use Illuminate\Notifications\Messages\MailMessage;
  10. use Illuminate\Support\Facades\URL;
  11.  
  12. class EmailChangeNotification extends Notification implements ShouldQueue
  13. {
  14. use Queueable;
  15.  
  16. /**
  17. * The user Email
  18. *
  19. * @var string
  20. */
  21. protected $userId;
  22.  
  23. /**
  24. * Create a new notification instance.
  25. *
  26. * @param string $userId
  27. */
  28. public function __construct(string $userId)
  29. {
  30. $this->userId = $userId;
  31. }
  32.  
  33. /**
  34. * Get the notification's delivery channels.
  35. *
  36. * @param mixed $notifiable
  37. * @return array
  38. */
  39. public function via($notifiable)
  40. {
  41. return ['mail'];
  42. }
  43.  
  44. /**
  45. * Get the mail representation of the notification.
  46. *
  47. * @param mixed $notifiable
  48. * @return \Illuminate\Notifications\Messages\MailMessage
  49. */
  50. public function toMail(AnonymousNotifiable $notifiable)
  51. {
  52. return (new MailMessage)->markdown('mail.email-reset', [
  53. 'notifiable' => $notifiable,
  54. 'route' => $this->verifyRoute($notifiable)
  55. ]);
  56. }
  57.  
  58. /**
  59. * Returns the Reset URl to send in the Email
  60. *
  61. * @param AnonymousNotifiable $notifiable
  62. * @return string
  63. */
  64. protected function verifyRoute(AnonymousNotifiable $notifiable)
  65. {
  66. return URL::temporarySignedRoute('user.email-change-verify', 60 * 60, [
  67. 'user' => $this->userId,
  68. 'email' => $notifiable->routes['mail']
  69. ]);
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement