Skip to content

Commit 7623140

Browse files
Update the stub resolution
1 parent f9fe846 commit 7623140

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

Diff for: src/Commands/FMModelMakeCommand.php

+17-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace GearboxSolutions\EloquentFileMaker\Commands;
44

55
use Illuminate\Foundation\Console\ModelMakeCommand as LaravelModelMakeCommand;
6-
use Illuminate\Support\Str;
76
use Symfony\Component\Console\Input\InputOption;
87

98
class FMModelMakeCommand extends LaravelModelMakeCommand
@@ -29,14 +28,29 @@ public function getStub()
2928
$stub = parent::getStub();
3029

3130
if ($this->option('filemaker')) {
32-
$stub = Str::replace('/model.', '/fm.model.', $stub);
31+
if ($this->option('pivot') || $this->option('morph-pivot')) {
32+
throw new \RuntimeException('This model type is not yet supported by Eloquent FileMaker.');
33+
}
3334

34-
throw_if(! file_exists($stub), new \RuntimeException('This model type is not yet supported by Eloquent FileMaker.'));
35+
$stub = $this->resolveStubPath('/stubs/fm.model.stub');
3536
}
3637

3738
return $stub;
3839
}
3940

41+
/**
42+
* Resolve the fully-qualified path to the stub.
43+
*
44+
* @param string $stub
45+
* @return string
46+
*/
47+
protected function resolveStubPath($stub)
48+
{
49+
return file_exists($customPath = $this->laravel->basePath(trim($stub, '/')))
50+
? $customPath
51+
: __DIR__ . $stub;
52+
}
53+
4054
protected function getOptions()
4155
{
4256
return array_merge(parent::getOptions(), [

0 commit comments

Comments
 (0)