This commit is contained in:
Lance Pioch 2024-03-19 04:52:43 -04:00
parent 3a95105931
commit c4c4834acc

View File

@ -26,19 +26,13 @@ class EggCreationService
{ {
$data['config_from'] = array_get($data, 'config_from'); $data['config_from'] = array_get($data, 'config_from');
if (!is_null($data['config_from'])) { if (!is_null($data['config_from'])) {
$results = Egg::query() $parentEgg = Egg::query()->find(array_get($data, 'config_from'));
->where('nest_id', array_get($data, 'nest_id')) throw_unless($parentEgg, new NoParentConfigurationFoundException(trans('exceptions.egg.invalid_copy_id')));
->where('id', array_get($data, 'config_from'))
->count();
if ($results !== 1) {
throw new NoParentConfigurationFoundException(trans('exceptions.egg.invalid_copy_id'));
}
} }
return Egg::query()->create(array_merge($data, [ return Egg::query()->create(array_merge($data, [
'uuid' => Uuid::uuid4()->toString(), 'uuid' => Uuid::uuid4()->toString(),
'author' => $this->config->get('pterodactyl.service.author'), 'author' => $this->config->get('panel.service.author'),
])); ]));
} }
} }