Path: blob/1.0-develop/app/Notifications/ServerInstalled.php
10266 views
<?php12namespace Pterodactyl\Notifications;34use Pterodactyl\Models\User;5use Illuminate\Bus\Queueable;6use Pterodactyl\Events\Event;7use Pterodactyl\Models\Server;8use Illuminate\Container\Container;9use Pterodactyl\Events\Server\Installed;10use Illuminate\Notifications\Notification;11use Illuminate\Contracts\Queue\ShouldQueue;12use Pterodactyl\Contracts\Core\ReceivesEvents;13use Illuminate\Contracts\Notifications\Dispatcher;14use Illuminate\Notifications\Messages\MailMessage;1516class ServerInstalled extends Notification implements ShouldQueue, ReceivesEvents17{18use Queueable;1920public Server $server;2122public User $user;2324/**25* Handle a direct call to this notification from the server installed event. This is configured26* in the event service provider.27*28* @phpstan-param Installed $event29*/30public function handle(Event|Installed $event): void31{32$event->server->loadMissing('user');3334$this->server = $event->server;35$this->user = $event->server->user;3637// Since we are calling this notification directly from an event listener we need to fire off the dispatcher38// to send the email now. Don't use send() or you'll end up firing off two different events.39Container::getInstance()->make(Dispatcher::class)->sendNow($this->user, $this);40}4142/**43* Get the notification's delivery channels.44*/45public function via(): array46{47return ['mail'];48}4950/**51* Get the mail representation of the notification.52*/53public function toMail(): MailMessage54{55return (new MailMessage())56->greeting('Hello ' . $this->user->username . '.')57->line('Your server has finished installing and is now ready for you to use.')58->line('Server Name: ' . $this->server->name)59->action('Login and Begin Using', route('index'));60}61}626364