File tree 1 file changed +17
-3
lines changed
1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change 3
3
namespace GearboxSolutions \EloquentFileMaker \Commands ;
4
4
5
5
use Illuminate \Foundation \Console \ModelMakeCommand as LaravelModelMakeCommand ;
6
- use Illuminate \Support \Str ;
7
6
use Symfony \Component \Console \Input \InputOption ;
8
7
9
8
class FMModelMakeCommand extends LaravelModelMakeCommand
@@ -29,14 +28,29 @@ public function getStub()
29
28
$ stub = parent ::getStub ();
30
29
31
30
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
+ }
33
34
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 ' );
35
36
}
36
37
37
38
return $ stub ;
38
39
}
39
40
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
+
40
54
protected function getOptions ()
41
55
{
42
56
return array_merge (parent ::getOptions (), [
You can’t perform that action at this time.
0 commit comments