Path: blob/1.0-develop/app/Services/Eggs/EggUpdateService.php
10281 views
<?php12namespace Pterodactyl\Services\Eggs;34use Pterodactyl\Models\Egg;5use Pterodactyl\Contracts\Repository\EggRepositoryInterface;6use Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException;78class EggUpdateService9{10/**11* EggUpdateService constructor.12*/13public function __construct(protected EggRepositoryInterface $repository)14{15}1617/**18* Update a service option.19*20* @throws \Pterodactyl\Exceptions\Model\DataValidationException21* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException22* @throws NoParentConfigurationFoundException23*/24public function handle(Egg $egg, array $data): void25{26if (!is_null(array_get($data, 'config_from'))) {27$results = $this->repository->findCountWhere([28['nest_id', '=', $egg->nest_id],29['id', '=', array_get($data, 'config_from')],30]);3132if ($results !== 1) {33throw new NoParentConfigurationFoundException(trans('exceptions.nest.egg.must_be_child'));34}35}3637// TODO(dane): Once the admin UI is done being reworked and this is exposed38// in said UI, remove this so that you can actually update the denylist.39unset($data['file_denylist']);4041$this->repository->withoutFreshModel()->update($egg->id, $data);42}43}444546