From 5b407c912eac74d40a98922c73372afc39f83a0f Mon Sep 17 00:00:00 2001 From: Sam Maosa Date: Tue, 24 Oct 2023 06:44:22 +0300 Subject: [PATCH] New Feature: Loop in Substitution until all keys are substituted. --- src/Helpers/Framework.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Helpers/Framework.php b/src/Helpers/Framework.php index 466f2ae..d9303ba 100644 --- a/src/Helpers/Framework.php +++ b/src/Helpers/Framework.php @@ -75,7 +75,11 @@ public function substitute(string $expression, array $substitutions = [], string $keys = collect($substitutions)->keys()->map(fn ($key) => "{$substitutionIdentifier}{$key}"); $values = collect($substitutions)->values(); - return Str::of($expression)->replace($keys->toArray(), $values->toArray())->toString(); + $replacement = Str::of($expression)->replace($keys->toArray(), $values->toArray())->toString(); + while (Str::of($replacement)->contains($keys)) { + $replacement = $this->substitute($replacement,$substitutions,$substitutionIdentifier); + } + return $replacement; } public function getByCode(Model | string $model, string|array $code)