2017-02-18 00:23:27 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Observers;
|
|
|
|
|
|
|
|
use Pterodactyl\Events;
|
|
|
|
use Pterodactyl\Models\Subuser;
|
|
|
|
use Pterodactyl\Notifications\AddedToServer;
|
|
|
|
use Pterodactyl\Notifications\RemovedFromServer;
|
|
|
|
|
|
|
|
class SubuserObserver
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Listen to the Subuser creating event.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function creating(Subuser $subuser): void
|
2017-02-18 00:23:27 +00:00
|
|
|
{
|
|
|
|
event(new Events\Subuser\Creating($subuser));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Listen to the Subuser created event.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function created(Subuser $subuser): void
|
2017-02-18 00:23:27 +00:00
|
|
|
{
|
|
|
|
event(new Events\Subuser\Created($subuser));
|
|
|
|
|
2022-10-14 16:59:20 +00:00
|
|
|
$subuser->user->notify(new AddedToServer([
|
2017-02-18 00:23:27 +00:00
|
|
|
'user' => $subuser->user->name_first,
|
|
|
|
'name' => $subuser->server->name,
|
|
|
|
'uuidShort' => $subuser->server->uuidShort,
|
2022-10-14 16:59:20 +00:00
|
|
|
]));
|
2017-02-18 00:23:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Listen to the Subuser deleting event.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function deleting(Subuser $subuser): void
|
2017-02-18 00:23:27 +00:00
|
|
|
{
|
|
|
|
event(new Events\Subuser\Deleting($subuser));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Listen to the Subuser deleted event.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function deleted(Subuser $subuser): void
|
2017-02-18 00:23:27 +00:00
|
|
|
{
|
|
|
|
event(new Events\Subuser\Deleted($subuser));
|
|
|
|
|
2022-10-14 16:59:20 +00:00
|
|
|
$subuser->user->notify(new RemovedFromServer([
|
2017-02-18 00:23:27 +00:00
|
|
|
'user' => $subuser->user->name_first,
|
|
|
|
'name' => $subuser->server->name,
|
2022-10-14 16:59:20 +00:00
|
|
|
]));
|
2017-02-18 00:23:27 +00:00
|
|
|
}
|
|
|
|
}
|