From ce125adaa8fd845f81038ed8c7f680837c500535 Mon Sep 17 00:00:00 2001 From: obayd Date: Fri, 17 Apr 2020 07:22:29 +0300 Subject: [PATCH 1/2] fix models namespace issues --- src/Generators/ControllerGenerator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Generators/ControllerGenerator.php b/src/Generators/ControllerGenerator.php index ea5820a0..b0c48e9a 100644 --- a/src/Generators/ControllerGenerator.php +++ b/src/Generators/ControllerGenerator.php @@ -207,7 +207,7 @@ private function fullyQualifyModelReference(string $sub_namespace, string $model /** @var \Blueprint\Models\Model $model */ $model = $this->modelForContext($model_name); - if (isset($this->models[Str::studly($model_name)])) { + if (isset($model)) { return $model->fullyQualifiedClassName(); } @@ -221,7 +221,7 @@ private function modelForContext(string $context) } $matches = array_filter(array_keys($this->models), function ($key) use ($context) { - return Str::endsWith($key, '/'.Str::studly($context)); + return Str::endsWith(preg_replace('/.+\\\\/', '', $key), Str::studly($context)); }); if (count($matches) === 1) { From 31bdd23c81dc78196fed5b8c29e93d76c0fabcdb Mon Sep 17 00:00:00 2001 From: Jason McCreary Date: Fri, 17 Apr 2020 12:10:54 -0400 Subject: [PATCH 2/2] Revert regular expression --- src/Generators/ControllerGenerator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Generators/ControllerGenerator.php b/src/Generators/ControllerGenerator.php index b0c48e9a..dc8987c9 100644 --- a/src/Generators/ControllerGenerator.php +++ b/src/Generators/ControllerGenerator.php @@ -221,7 +221,7 @@ private function modelForContext(string $context) } $matches = array_filter(array_keys($this->models), function ($key) use ($context) { - return Str::endsWith(preg_replace('/.+\\\\/', '', $key), Str::studly($context)); + return Str::endsWith($key, '/'.Str::studly($context)); }); if (count($matches) === 1) {