File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change 33namespace GearboxSolutions \EloquentFileMaker \Commands ;
44
55use Illuminate \Foundation \Console \ModelMakeCommand as LaravelModelMakeCommand ;
6- use Illuminate \Support \Str ;
76use Symfony \Component \Console \Input \InputOption ;
87
98class 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 (), [
You can’t perform that action at this time.
0 commit comments