Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/app/Services/Nests/NestUpdateService.php
10262 views
1
<?php
2
3
namespace Pterodactyl\Services\Nests;
4
5
use Pterodactyl\Contracts\Repository\NestRepositoryInterface;
6
7
class NestUpdateService
8
{
9
/**
10
* NestUpdateService constructor.
11
*/
12
public function __construct(protected NestRepositoryInterface $repository)
13
{
14
}
15
16
/**
17
* Update a nest and prevent changing the author once it is set.
18
*
19
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
20
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
21
*/
22
public function handle(int $nest, array $data): void
23
{
24
if (!is_null(array_get($data, 'author'))) {
25
unset($data['author']);
26
}
27
28
$this->repository->withoutFreshModel()->update($nest, $data);
29
}
30
}
31
32