Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/app/Traits/Services/HasUserLevels.php
10284 views
1
<?php
2
3
namespace Pterodactyl\Traits\Services;
4
5
use Pterodactyl\Models\User;
6
7
trait HasUserLevels
8
{
9
private int $userLevel = User::USER_LEVEL_USER;
10
11
/**
12
* Set the access level for running this function.
13
*/
14
public function setUserLevel(int $level): self
15
{
16
$this->userLevel = $level;
17
18
return $this;
19
}
20
21
/**
22
* Determine which level this function is running at.
23
*/
24
public function getUserLevel(): int
25
{
26
return $this->userLevel;
27
}
28
29
/**
30
* Determine if the current user level is set to a specific level.
31
*/
32
public function isUserLevel(int $level): bool
33
{
34
return $this->getUserLevel() === $level;
35
}
36
}
37
38