From 24a8bfab97656378a62cf09618b978867b761b04 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 12 Feb 2017 16:26:55 -0500 Subject: [PATCH] Update server observer to use new model code. --- app/Observers/ServerObserver.php | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/app/Observers/ServerObserver.php b/app/Observers/ServerObserver.php index 626847aa4..e4b00e000 100644 --- a/app/Observers/ServerObserver.php +++ b/app/Observers/ServerObserver.php @@ -26,7 +26,6 @@ namespace Pterodactyl\Observers; use Carbon; use Pterodactyl\Events; -use Pterodactyl\Models; use Pterodactyl\Models\Server; use Pterodactyl\Jobs\DeleteServer; use Pterodactyl\Jobs\SuspendServer; @@ -59,20 +58,14 @@ class ServerObserver event(new Events\Server\Created($server)); // Queue Notification Email - $user = Models\User::findOrFail($server->owner_id); - $node = Models\Node::select('name')->where('id', $server->node_id)->first(); - $service = Models\Service::select('services.name', 'service_options.name as optionName') - ->join('service_options', 'service_options.service_id', '=', 'services.id') - ->where('services.id', $server->service_id) - ->where('service_options.id', $server->option_id) - ->first(); + $server->load('user', 'node', 'service.option'); - $user->notify((new ServerCreated([ + $server->user->notify((new ServerCreated([ 'name' => $server->name, 'memory' => $server->memory, - 'node' => $node->name, - 'service' => $service->name, - 'option' => $service->optionName, + 'node' => $server->node->name, + 'service' => $server->service->name, + 'option' => $server->service->option->name, 'uuidShort' => $server->uuidShort, ]))); }