Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/Generators/EntityGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,18 @@ abstract public function generate(): void;

protected function classExists(string $path, string $name, ?string $subFolder = null): bool
{
$classPath = $this->getClassPath($path, $name, $subFolder);
$relativePath = $this->getClassPath($path, $name, $subFolder);

return file_exists($classPath);
$absolutePath = base_path($relativePath);

return file_exists($absolutePath);
}

protected function getClassPath(string $path, string $name, ?string $subFolder = null): string
{
$path = $this->getPath($path, $subFolder);

return base_path("{$path}/{$name}.php");
return "{$path}/{$name}.php";
}

protected function saveClass($path, $name, $content, ?string $entityFolder = null): string
Expand Down
2 changes: 0 additions & 2 deletions src/Generators/NovaTestGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Laravel\Nova\NovaServiceProvider;
use Laravel\Nova\Http\Requests\NovaRequest;
use RonasIT\Support\Events\SuccessCreateMessage;
use RonasIT\Support\Exceptions\ClassAlreadyExistsException;
use RonasIT\Support\Exceptions\ClassNotExistsException;
use RonasIT\Support\Exceptions\EntityCreateException;
use Generator;
Expand Down Expand Up @@ -43,7 +42,6 @@ public function generate(): void
}

if (empty($novaResources)) {
// TODO: pass $this->modelSubfolder to Exception after refactoring in https://github.com/RonasIT/laravel-entity-generator/issues/179
$this->throwFailureException(
ClassNotExistsException::class,
"Cannot create Nova{$this->model}ResourceTest cause {$this->model} Nova resource does not exist.",
Expand Down
2 changes: 1 addition & 1 deletion tests/ControllerGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testControllerAlreadyExists()

$this->assertExceptionThrew(
className: ResourceAlreadyExistsException::class,
message: 'Cannot create PostController cause it already exists. Remove vfs://root/app/Http/Controllers/PostController.php and run command again.',
message: 'Cannot create PostController cause it already exists. Remove app/Http/Controllers/PostController.php and run command again.',
);

app(ControllerGenerator::class)
Expand Down
2 changes: 1 addition & 1 deletion tests/FactoryGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function testFactoryClassExists()
{
$this->assertExceptionThrew(
className: ResourceAlreadyExistsException::class,
message: 'Cannot create PostFactory cause it already exists. Remove vfs://root/database/factories/PostFactory.php and run command again.',
message: 'Cannot create PostFactory cause it already exists. Remove database/factories/PostFactory.php and run command again.',
);

$this->mockFactoryGenerator(
Expand Down
2 changes: 1 addition & 1 deletion tests/ModelGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testModelAlreadyExists()

$this->assertExceptionThrew(
className: ResourceAlreadyExistsException::class,
message: 'Cannot create Post cause it already exists. Remove vfs://root/app/Models/Blog/Post.php and run command again.',
message: 'Cannot create Post cause it already exists. Remove app/Models/Blog/Post.php and run command again.',
);

app(ModelGenerator::class)
Expand Down
2 changes: 1 addition & 1 deletion tests/NovaResourceGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function testCreateNovaTestAlreadyExists()

$this->assertExceptionThrew(
className: ResourceAlreadyExistsException::class,
message: 'Cannot create PostResource cause it already exists. Remove vfs://root/app/Nova/PostResource.php and run command again.',
message: 'Cannot create PostResource cause it already exists. Remove app/Nova/PostResource.php and run command again.',
);

app(NovaResourceGenerator::class)
Expand Down
2 changes: 1 addition & 1 deletion tests/NovaTestGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function testGenerateNovaTestAlreadyExists()

$this->assertExceptionThrew(
className: ResourceAlreadyExistsException::class,
message: "Cannot create NovaPostResourceTest cause it already exists. Remove vfs://root/app/Nova/NovaPostResourceTest.php and run command again.",
message: "Cannot create NovaPostResourceTest cause it already exists. Remove app/Nova/NovaPostResourceTest.php and run command again.",
);

app(NovaTestGenerator::class)
Expand Down
4 changes: 2 additions & 2 deletions tests/ResourceGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function testResourceAlreadyExists()

$this->assertExceptionThrew(
className: ResourceAlreadyExistsException::class,
message: 'Cannot create PostResource cause it already exists. Remove vfs://root/app/Http/Resources/PostResource.php and run command again.',
message: 'Cannot create PostResource cause it already exists. Remove app/Http/Resources/PostResource.php and run command again.',
);

app(ResourceGenerator::class)
Expand All @@ -37,7 +37,7 @@ public function testCollectionResourceAlreadyExists()

$this->assertExceptionThrew(
className: ResourceAlreadyExistsException::class,
message: 'Cannot create PostsCollectionResource cause it already exists. Remove vfs://root/app/Http/Resources/PostsCollectionResource.php and run command again.',
message: 'Cannot create PostsCollectionResource cause it already exists. Remove app/Http/Resources/PostsCollectionResource.php and run command again.',
);

app(ResourceGenerator::class)
Expand Down