Files

63 lines
1.6 KiB
PHP
Raw Permalink Normal View History

<?php
2026-10-05 18:10:18 -04:00
declare(strict_types=1);
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;
2026-10-05 18:10:18 -04:00
class ServerInstalled extends Notification implements ReceivesEvents, ShouldQueue
{
use Queueable;
2022-10-14 10:59:20 -06:00
public Server $server;
2022-10-14 10:59:20 -06:00
public User $user;
/**
* Handle a direct call to this notification from the server installed event. This is configured
* in the event service provider.
*
* @phpstan-param Installed $event
*/
2022-10-14 10:59:20 -06:00
public function handle(Event|Installed $event): void
{
$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);
}
/**
* Get the notification's delivery channels.
2026-10-05 18:10:18 -04:00
*
* @return list<string>
*/
2022-10-14 10:59:20 -06:00
public function via(): array
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*/
2022-10-14 10:59:20 -06:00
public function toMail(): MailMessage
{
2026-10-05 18:10:18 -04:00
return (new MailMessage)
->greeting('Hello '.$this->user->username.'.')
->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)
->action('Login and Begin Using', route('index'));
}
}