cbcf62086f
Co-authored-by: DaneEveritt <dane@daneeveritt.com>
30 lines
756 B
PHP
30 lines
756 B
PHP
<?php
|
|
|
|
namespace Pterodactyl\Services\Nests;
|
|
|
|
use Pterodactyl\Contracts\Repository\NestRepositoryInterface;
|
|
|
|
class NestUpdateService
|
|
{
|
|
/**
|
|
* NestUpdateService constructor.
|
|
*/
|
|
public function __construct(protected NestRepositoryInterface $repository)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Update a nest and prevent changing the author once it is set.
|
|
*
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
|
*/
|
|
public function handle(int $nest, array $data): void
|
|
{
|
|
if (!is_null(array_get($data, 'author'))) {
|
|
unset($data['author']);
|
|
}
|
|
|
|
$this->repository->withoutFreshModel()->update($nest, $data);
|
|
}
|
|
}
|