Last active
March 14, 2019 21:22
-
-
Save DarkGhostHunter/3133cd7d2eed7760065d13eaa6447b53 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace App\Notifications; | |
| use Illuminate\Bus\Queueable; | |
| use Illuminate\Notifications\AnonymousNotifiable; | |
| use Illuminate\Notifications\Notification; | |
| use Illuminate\Contracts\Queue\ShouldQueue; | |
| use Illuminate\Notifications\Messages\MailMessage; | |
| use Illuminate\Support\Facades\URL; | |
| class EmailChangeNotification extends Notification implements ShouldQueue | |
| { | |
| use Queueable; | |
| /** | |
| * The user Email | |
| * | |
| * @var string | |
| */ | |
| protected $userId; | |
| /** | |
| * Create a new notification instance. | |
| * | |
| * @param string $userId | |
| */ | |
| public function __construct(string $userId) | |
| { | |
| $this->userId = $userId; | |
| } | |
| /** | |
| * Get the notification's delivery channels. | |
| * | |
| * @param mixed $notifiable | |
| * @return array | |
| */ | |
| public function via($notifiable) | |
| { | |
| return ['mail']; | |
| } | |
| /** | |
| * Get the mail representation of the notification. | |
| * | |
| * @param mixed $notifiable | |
| * @return \Illuminate\Notifications\Messages\MailMessage | |
| */ | |
| public function toMail(AnonymousNotifiable $notifiable) | |
| { | |
| return (new MailMessage)->markdown('mail.email-reset', [ | |
| 'notifiable' => $notifiable, | |
| 'route' => $this->verifyRoute($notifiable) | |
| ]); | |
| } | |
| /** | |
| * Returns the Reset URl to send in the Email | |
| * | |
| * @param AnonymousNotifiable $notifiable | |
| * @return string | |
| */ | |
| protected function verifyRoute(AnonymousNotifiable $notifiable) | |
| { | |
| return URL::temporarySignedRoute('user.email-change-verify', 60 * 60, [ | |
| 'user' => $this->userId, | |
| 'email' => $notifiable->routes['mail'] | |
| ]); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment