parser->handle($file); return $this->connection->transaction(function () use ($parsed) { $egg = (new Egg())->forceFill([ 'uuid' => Uuid::uuid4()->toString(), '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; }); } }