36 lines
987 B
PHP
36 lines
987 B
PHP
<?php
|
|
|
|
namespace Pterodactyl\Services\Eggs;
|
|
|
|
use Pterodactyl\Models\Egg;
|
|
use Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException;
|
|
|
|
class EggUpdateService
|
|
{
|
|
/**
|
|
* Update a service option.
|
|
*
|
|
* @throws NoParentConfigurationFoundException
|
|
*/
|
|
public function handle(Egg $egg, array $data): void
|
|
{
|
|
$eggId = array_get($data, 'config_from');
|
|
if (!is_null($eggId)) {
|
|
$results = Egg::query()
|
|
->where('nest_id', $egg->nest_id)
|
|
->where('id', $eggId)
|
|
->count();
|
|
|
|
if ($results !== 1) {
|
|
throw new NoParentConfigurationFoundException(trans('exceptions.nest.egg.must_be_child'));
|
|
}
|
|
}
|
|
|
|
// TODO: (Dane) Once the admin UI is done being reworked and this is exposed
|
|
// in said UI, remove this so that you can actually update the denylist.
|
|
unset($data['file_denylist']);
|
|
|
|
$egg->update($data);
|
|
}
|
|
}
|