-
app/Traits/Services/HasUserLevels.php
Open in GitHubuse App\Models\User; trait HasUserLevels { private int $userLevel = User::USER_LEVEL_USER; public function setUserLevel(int $level): self { $this->userLevel = $level; return $this; } public function getUserLevel(): int { return $this->userLevel; } public function isUserLevel(int $level): bool { return $this->getUserLevel() === $level; } }
-
app/Services/Servers/StartupModificationService.php
Open in GitHubuse App\Models\Server; use App\Traits\Services\HasUserLevels; class StartupModificationService { use HasUserLevels; // ... public function handle(Server $server, array $data): Server { return $this->connection->transaction(function () use ($server, $data) { // ... if ($this->isUserLevel(User::USER_LEVEL_ADMIN)) { $this->updateAdministrativeSettings($data, $server); } return $server->fresh(); }); } // ... }