2018-07-01 23:34:40 +02:00
|
|
|
<?php
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2018-07-01 23:34:40 +02:00
|
|
|
namespace Pterodactyl\Notifications;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
2026-10-05 18:10:18 -04:00
|
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
|
use Pterodactyl\Contracts\Core\ReceivesEvents;
|
|
|
|
|
use Pterodactyl\Events\Event;
|
|
|
|
|
use Pterodactyl\Events\Server\Installed;
|
|
|
|
|
use Pterodactyl\Models\Server;
|
|
|
|
|
use Pterodactyl\Models\User;
|
2018-07-01 23:34:40 +02:00
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
class ServerInstalled extends Notification implements ReceivesEvents, ShouldQueue
|
2018-07-01 23:34:40 +02:00
|
|
|
{
|
|
|
|
|
use Queueable;
|
|
|
|
|
|
2022-10-14 10:59:20 -06:00
|
|
|
public Server $server;
|
2018-07-01 23:34:40 +02:00
|
|
|
|
2022-10-14 10:59:20 -06:00
|
|
|
public User $user;
|
2018-07-01 23:34:40 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handle a direct call to this notification from the server installed event. This is configured
|
|
|
|
|
* in the event service provider.
|
2025-12-20 15:55:13 -08:00
|
|
|
*
|
|
|
|
|
* @phpstan-param Installed $event
|
2018-07-01 23:34:40 +02:00
|
|
|
*/
|
2022-10-14 10:59:20 -06:00
|
|
|
public function handle(Event|Installed $event): void
|
2018-07-01 23:34:40 +02:00
|
|
|
{
|
|
|
|
|
$event->server->loadMissing('user');
|
|
|
|
|
|
|
|
|
|
$this->server = $event->server;
|
|
|
|
|
$this->user = $event->server->user;
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
$this->user->notifyNow($this);
|
2018-07-01 23:34:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the notification's delivery channels.
|
2026-10-05 18:10:18 -04:00
|
|
|
*
|
|
|
|
|
* @return list<string>
|
2018-07-01 23:34:40 +02:00
|
|
|
*/
|
2022-10-14 10:59:20 -06:00
|
|
|
public function via(): array
|
2018-07-01 23:34:40 +02:00
|
|
|
{
|
|
|
|
|
return ['mail'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the mail representation of the notification.
|
|
|
|
|
*/
|
2022-10-14 10:59:20 -06:00
|
|
|
public function toMail(): MailMessage
|
2018-07-01 23:34:40 +02:00
|
|
|
{
|
2026-10-05 18:10:18 -04:00
|
|
|
return (new MailMessage)
|
|
|
|
|
->greeting('Hello '.$this->user->username.'.')
|
2018-07-01 23:34:40 +02:00
|
|
|
->line('Your server has finished installing and is now ready for you to use.')
|
2026-10-05 18:10:18 -04:00
|
|
|
->line('Server Name: '.$this->server->name)
|
2018-07-01 23:34:40 +02:00
|
|
|
->action('Login and Begin Using', route('index'));
|
|
|
|
|
}
|
|
|
|
|
}
|