blue-twilight/app/Notifications/ResetPassword.php

78 lines
1.7 KiB
PHP

<?php
namespace App\Notifications;
use App\Facade\UserConfig;
use App\Mail\MailableBase;
use App\Mail\ResetMyPassword;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
class ResetPassword extends Notification
{
use Queueable;
/**
* The password reset token.
*
* @var string
*/
public $token;
/**
* Create a notification instance.
*
* @param string $token
* @return void
*/
public function __construct($token)
{
$this->token = $token;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
$drivers = [];
if (UserConfig::get('queue_emails'))
{
$drivers[] = QueueEmailDatabaseChannel::class;
}
else
{
$drivers[] = 'mail';
$drivers[] = SentEmailDatabaseChannel::class;
}
return $drivers;
}
public function toEmailDatabase($notifiable)
{
return $this->toMail($notifiable)->buildEmailLog();
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage|MailableBase
*/
public function toMail($notifiable)
{
$notification = new ResetMyPassword($notifiable, $this->token);
// Set to and from properties accordingly
$notification->from(UserConfig::get('sender_address'), UserConfig::get('sender_name'));
$notification->to($notifiable->email, $notifiable->name);
return $notification;
}
}