@@ -34,7 +34,7 @@ public function directoryCreate()
34
34
public function generateController ()
35
35
{
36
36
if (! file_exists (base_path ('app/Http/Controllers/Api/ ' .$ this ->model .'Controller.php ' ))) {
37
- $ template = file_get_contents ( self ::STUB_DIR . 'controller.stub ' );
37
+ $ template = self ::getStubContents ( 'controller.stub ' );
38
38
$ template = str_replace ('{{modelName}} ' , $ this ->model , $ template );
39
39
$ template = str_replace ('{{modelNameLower}} ' , strtolower ($ this ->model ), $ template );
40
40
$ template = str_replace ('{{modelNameCamel}} ' , Str::camel ($ this ->model ), $ template );
@@ -48,7 +48,7 @@ public function generateController()
48
48
public function generateResource ()
49
49
{
50
50
if (! file_exists (base_path ('app/Http/Resources/ ' .$ this ->model .'Resource.php ' ))) {
51
- $ template = file_get_contents ( self ::STUB_DIR . 'resource.stub ' );
51
+ $ template = self ::getStubContents ( 'resource.stub ' );
52
52
$ template = str_replace ('{{modelName}} ' , $ this ->model , $ template );
53
53
file_put_contents (base_path ('app/Http/Resources/ ' .$ this ->model .'Resource.php ' ), $ template );
54
54
$ this ->result = true ;
@@ -60,7 +60,7 @@ public function generateResource()
60
60
public function generateCollection ()
61
61
{
62
62
if (! file_exists (base_path ('app/Http/Resources/ ' .$ this ->model .'Collection.php ' ))) {
63
- $ template = file_get_contents ( self ::STUB_DIR . 'collection.stub ' );
63
+ $ template = self ::getStubContents ( 'collection.stub ' );
64
64
$ template = str_replace ('{{modelName}} ' , $ this ->model , $ template );
65
65
file_put_contents (base_path ('app/Http/Resources/ ' .$ this ->model .'Collection.php ' ), $ template );
66
66
$ this ->result = true ;
@@ -81,4 +81,8 @@ public function generateRoute()
81
81
82
82
return $ this ->result ;
83
83
}
84
+
85
+ private function getStubContents ($ stubName ){
86
+ return file_get_contents (self ::STUB_DIR .$ stubName );
87
+ }
84
88
}
0 commit comments