2016-09-05 16:00:56 +00:00
|
|
|
<?php
|
2016-12-07 22:46:38 +00:00
|
|
|
|
2016-09-05 16:00:56 +00:00
|
|
|
namespace Pterodactyl\Notifications;
|
|
|
|
|
2018-01-01 18:13:08 +00:00
|
|
|
use Pterodactyl\Models\User;
|
2016-09-05 16:00:56 +00:00
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
|
|
|
|
|
|
class AccountCreated extends Notification implements ShouldQueue
|
|
|
|
{
|
|
|
|
use Queueable;
|
|
|
|
|
|
|
|
/**
|
2018-01-01 18:13:08 +00:00
|
|
|
* The authentication token to be used for the user to set their
|
|
|
|
* password for the first time.
|
|
|
|
*
|
|
|
|
* @var string|null
|
|
|
|
*/
|
|
|
|
public $token;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The user model for the created user.
|
2016-09-05 16:00:56 +00:00
|
|
|
*
|
2018-07-01 01:47:31 +00:00
|
|
|
* @var \Pterodactyl\Models\User
|
2016-09-05 16:00:56 +00:00
|
|
|
*/
|
2017-02-18 00:35:26 +00:00
|
|
|
public $user;
|
2016-09-05 16:00:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new notification instance.
|
|
|
|
*
|
2018-01-01 18:13:08 +00:00
|
|
|
* @param \Pterodactyl\Models\User $user
|
2019-09-06 04:32:57 +00:00
|
|
|
* @param string|null $token
|
2016-09-05 16:00:56 +00:00
|
|
|
*/
|
2018-01-01 18:13:08 +00:00
|
|
|
public function __construct(User $user, string $token = null)
|
2016-09-05 16:00:56 +00:00
|
|
|
{
|
2018-01-01 18:13:08 +00:00
|
|
|
$this->token = $token;
|
|
|
|
$this->user = $user;
|
2016-09-05 16:00:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the notification's delivery channels.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param mixed $notifiable
|
2016-09-05 16:00:56 +00:00
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function via($notifiable)
|
|
|
|
{
|
2016-10-14 19:58:52 +00:00
|
|
|
return ['mail'];
|
2016-09-05 16:00:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the mail representation of the notification.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param mixed $notifiable
|
2016-09-05 16:00:56 +00:00
|
|
|
* @return \Illuminate\Notifications\Messages\MailMessage
|
|
|
|
*/
|
|
|
|
public function toMail($notifiable)
|
|
|
|
{
|
2017-02-18 00:26:02 +00:00
|
|
|
$message = (new MailMessage)
|
2017-02-17 23:48:57 +00:00
|
|
|
->greeting('Hello ' . $this->user->name . '!')
|
2018-05-06 18:22:30 +00:00
|
|
|
->line('You are receiving this email because an account has been created for you on ' . config('app.name') . '.')
|
2017-02-17 23:48:57 +00:00
|
|
|
->line('Username: ' . $this->user->username)
|
2018-01-01 18:13:08 +00:00
|
|
|
->line('Email: ' . $this->user->email);
|
2017-02-18 00:26:02 +00:00
|
|
|
|
2018-01-01 18:13:08 +00:00
|
|
|
if (! is_null($this->token)) {
|
2018-07-01 01:47:31 +00:00
|
|
|
return $message->action('Setup Your Account', url('/auth/password/reset/' . $this->token . '?email=' . urlencode($this->user->email)));
|
2017-02-18 00:26:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return $message;
|
2016-09-05 16:00:56 +00:00
|
|
|
}
|
|
|
|
}
|