parser->handle($file); /** @var \Pterodactyl\Models\Nest $nest */ $nest = Nest::query()->with('eggs', 'eggs.variables')->findOrFail($nest); return $this->connection->transaction(function () use ($nest, $parsed) { $egg = (new Egg())->forceFill([ 'uuid' => Uuid::uuid4()->toString(), 'nest_id' => $nest->id, 'author' => Arr::get($parsed, 'author'), 'copy_script_from' => null, ]); $egg = $this->parser->fillFromParsed($egg, $parsed); $egg->save(); foreach ($parsed['variables'] ?? [] as $variable) { EggVariable::query()->forceCreate(array_merge($variable, ['egg_id' => $egg->id])); } return $egg; }); } }