<?php namespace App\Notifications; use App\Models\User; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Lang; class ConfirmEmail extends Notification { /** * The email confirm token. * * @var string */ public $token; /** * The new e-mail * * @var string */ public $newEmail; /** * Create a new notification instance. * * @return void */ public function __construct($newEmail, $token) { $this->newEmail = $newEmail; $this->token = $token; } /** * 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($notifiable) { /** @var User $notifiable */ $notifiable->email = $this->newEmail; // hack to send to the new e-mail return (new MailMessage) ->subject('E-Mail Confirmation') ->line( 'Please confirm that you just requested using this e-mail with the datatable.directory account '.$notifiable->handle.'. It will be used to login, to recover forgotten passwords, and for sending notifications. You can always opt out of e-mail notifications in the settings.') ->action('Confirm E-Mail', url(config('app.url').route('confirm-email', ['token' => $this->token], false))) ->line( 'If you did not request this action, no further action is required. The confirmation link will expire in a few hours.'); } }