Path: blob/1.0-develop/app/Notifications/ServerInstalled.php
7432 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*/28public function handle(Event|Installed $event): void29{30$event->server->loadMissing('user');3132$this->server = $event->server;33$this->user = $event->server->user;3435// Since we are calling this notification directly from an event listener we need to fire off the dispatcher36// to send the email now. Don't use send() or you'll end up firing off two different events.37Container::getInstance()->make(Dispatcher::class)->sendNow($this->user, $this);38}3940/**41* Get the notification's delivery channels.42*/43public function via(): array44{45return ['mail'];46}4748/**49* Get the mail representation of the notification.50*/51public function toMail(): MailMessage52{53return (new MailMessage())54->greeting('Hello ' . $this->user->username . '.')55->line('Your server has finished installing and is now ready for you to use.')56->line('Server Name: ' . $this->server->name)57->action('Login and Begin Using', route('index'));58}59}606162