forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSubuserObserver.php
More file actions
54 lines (46 loc) · 1.29 KB
/
SubuserObserver.php
File metadata and controls
54 lines (46 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?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.
*/
public function creating(Subuser $subuser): void
{
event(new Events\Subuser\Creating($subuser));
}
/**
* Listen to the Subuser created event.
*/
public function created(Subuser $subuser): void
{
event(new Events\Subuser\Created($subuser));
$subuser->user->notify(new AddedToServer([
'user' => $subuser->user->name_first,
'name' => $subuser->server->name,
'uuidShort' => $subuser->server->uuidShort,
]));
}
/**
* Listen to the Subuser deleting event.
*/
public function deleting(Subuser $subuser): void
{
event(new Events\Subuser\Deleting($subuser));
}
/**
* Listen to the Subuser deleted event.
*/
public function deleted(Subuser $subuser): void
{
event(new Events\Subuser\Deleted($subuser));
$subuser->user->notify(new RemovedFromServer([
'user' => $subuser->user->name_first,
'name' => $subuser->server->name,
]));
}
}