Skip to content

Commit a84700a

Browse files
authored
Merge pull request #43 from jdrieghe/main
Always use default ViewModels namespace as a prefix
2 parents 67a0652 + 3810a0b commit a84700a

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

src/Console/ViewModelMakeCommand.php

-9
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ protected function getStub()
3030

3131
protected function getDefaultNamespace($rootNamespace)
3232
{
33-
if ($this->isCustomNamespace()) {
34-
return $rootNamespace;
35-
}
36-
3733
return $rootNamespace.'\ViewModels';
3834
}
3935

@@ -43,9 +39,4 @@ protected function getOptions(): array
4339
['force', null, InputOption::VALUE_NONE, 'Create the class even if the view-model already exists'],
4440
];
4541
}
46-
47-
protected function isCustomNamespace(): bool
48-
{
49-
return Str::contains($this->argument('name'), '/');
50-
}
5142
}

tests/ViewModelMakeCommandTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ public function it_can_create_a_view_model_with_a_custom_namespace()
4242

4343
$this->assertStringContainsString('ViewModel created successfully.', Artisan::output());
4444

45-
$shouldOutputFilePath = $this->app['path'].'/Blog/PostsViewModel.php';
45+
$shouldOutputFilePath = $this->app['path'].'/ViewModels/Blog/PostsViewModel.php';
4646

4747
$this->assertTrue(File::exists($shouldOutputFilePath), 'File exists in custom app/Blog folder');
4848

4949
$contents = File::get($shouldOutputFilePath);
5050

51-
$this->assertStringContainsString('namespace App\Blog;', $contents);
51+
$this->assertStringContainsString('namespace App\ViewModels\Blog;', $contents);
5252

5353
$this->assertStringContainsString('class PostsViewModel extends ViewModel', $contents);
5454
}

0 commit comments

Comments
 (0)