Repository: laravel-shift/blueprint (php)

Issue:
Model namespace not appended in the generated model factory class
<!-- PLEASE COMPLETE THIS TEMPLATE -->

- Laravel Version: 8.62.0
- PHP Version: 7.4.5
- Blueprint Version: 2.0.0
- Platform: Mac | Windows | Linux

### Issue:
When building a model with a namespace, the generated model factory does not append the provided namespace.

```php
<?php

namespace Database\Factories; // must be: namespace Database\Factories\Admin;
```

### draft.yaml:
```yaml
Admin\User:
    name: string
```


Pull request:
Append model namespace in the generated factory class.
Resolve #511.

Patch:
diff --git a/src/Generators/FactoryGenerator.php b/src/Generators/FactoryGenerator.php
index 9e37951..5584096 100644
--- a/src/Generators/FactoryGenerator.php
+++ b/src/Generators/FactoryGenerator.php
@@ -83,6 +83,7 @@ class FactoryGenerator implements Generator
             $stub = str_replace('definition()', 'definition(): array', $stub);
         }
 
+        $stub = str_replace('{{ namespace }}', 'Database\Factories' . ($model->namespace() ? '\\' . $model->namespace() : ''), $stub);
         $stub = str_replace('use {{ namespacedModel }};', $this->buildImports($model), $stub);
 
         return $stub;
diff --git a/stubs/factory.stub b/stubs/factory.stub
index bc895ed..e3e1073 100644
--- a/stubs/factory.stub
+++ b/stubs/factory.stub
@@ -1,6 +1,6 @@
 <?php
 
-namespace Database\Factories;
+namespace {{ namespace }};
 
 use Illuminate\Database\Eloquent\Factories\Factory;
 use Illuminate\Support\Str;


Test patch:
diff --git a/tests/fixtures/factories/nested-components.php b/tests/fixtures/factories/nested-components.php
index bdecdab..4c832d4 100644
--- a/tests/fixtures/factories/nested-components.php
+++ b/tests/fixtures/factories/nested-components.php
@@ -1,6 +1,6 @@
 <?php
 
-namespace Database\Factories;
+namespace Database\Factories\Admin;
 
 use Illuminate\Database\Eloquent\Factories\Factory;
 use Illuminate\Support\Str;
diff --git a/tests/fixtures/factories/nested-models.php b/tests/fixtures/factories/nested-models.php
index 453545c..50cba52 100644
--- a/tests/fixtures/factories/nested-models.php
+++ b/tests/fixtures/factories/nested-models.php
@@ -1,6 +1,6 @@
 <?php
 
-namespace Database\Factories;
+namespace Database\Factories\Screening;
 
 use Illuminate\Database\Eloquent\Factories\Factory;
 use Illuminate\Support\Str;