2019-07-13 21:40:13 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Notifications;
|
|
|
|
|
2019-07-14 12:13:58 +01:00
|
|
|
use App\Facade\UserConfig;
|
|
|
|
use App\Mail\MailableBase;
|
|
|
|
use App\Mail\ResetMyPassword;
|
2019-07-13 21:40:13 +01:00
|
|
|
use Illuminate\Bus\Queueable;
|
2019-07-14 12:13:58 +01:00
|
|
|
use Illuminate\Mail\Mailable;
|
2019-07-13 21:40:13 +01:00
|
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2019-07-14 12:13:58 +01:00
|
|
|
$drivers = [];
|
|
|
|
|
|
|
|
if (UserConfig::get('queue_emails'))
|
|
|
|
{
|
|
|
|
$drivers[] = QueueEmailDatabaseChannel::class;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$drivers[] = 'mail';
|
|
|
|
$drivers[] = SentEmailDatabaseChannel::class;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $drivers;
|
2019-07-13 21:40:13 +01:00
|
|
|
}
|
|
|
|
|
2019-07-14 12:13:58 +01:00
|
|
|
public function toQueueEmailDatabase($notifiable)
|
2019-07-13 21:40:13 +01:00
|
|
|
{
|
2019-07-14 12:13:58 +01:00
|
|
|
return $this->toMail($notifiable)->buildEmailLog();
|
2019-07-13 21:40:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-07-14 12:13:58 +01:00
|
|
|
* Get the mail representation of the notification.
|
2019-07-13 21:40:13 +01:00
|
|
|
*
|
|
|
|
* @param mixed $notifiable
|
2019-07-14 12:13:58 +01:00
|
|
|
* @return \Illuminate\Notifications\Messages\MailMessage|MailableBase
|
2019-07-13 21:40:13 +01:00
|
|
|
*/
|
2019-07-14 12:13:58 +01:00
|
|
|
public function toMail($notifiable)
|
2019-07-13 21:40:13 +01:00
|
|
|
{
|
2019-07-14 12:13:58 +01:00
|
|
|
$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;
|
2019-07-13 21:40:13 +01:00
|
|
|
}
|
|
|
|
}
|