Update server observer to use new model code.

This commit is contained in:
Dane Everitt 2017-02-12 16:26:55 -05:00
parent 53cd32aac8
commit 24a8bfab97
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53

View file

@ -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,
])));
}