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