mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-28 05:44:45 +02:00
44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Eggs;
|
|
|
|
use App\Models\Egg;
|
|
use App\Contracts\Repository\EggRepositoryInterface;
|
|
use App\Exceptions\Service\Egg\NoParentConfigurationFoundException;
|
|
|
|
class EggUpdateService
|
|
{
|
|
/**
|
|
* EggUpdateService constructor.
|
|
*/
|
|
public function __construct(protected EggRepositoryInterface $repository)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Update an egg.
|
|
*
|
|
* @throws \App\Exceptions\Model\DataValidationException
|
|
* @throws \App\Exceptions\Repository\RecordNotFoundException
|
|
* @throws \App\Exceptions\Service\Egg\NoParentConfigurationFoundException
|
|
*/
|
|
public function handle(Egg $egg, array $data): void
|
|
{
|
|
if (!is_null(array_get($data, 'config_from'))) {
|
|
$results = $this->repository->findCountWhere([
|
|
['id', '=', array_get($data, 'config_from')],
|
|
]);
|
|
|
|
if ($results !== 1) {
|
|
throw new NoParentConfigurationFoundException(trans('exceptions.egg.invalid_copy_id'));
|
|
}
|
|
}
|
|
|
|
// TODO: 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']);
|
|
|
|
$this->repository->withoutFreshModel()->update($egg->id, $data);
|
|
}
|
|
}
|