@@ -22,7 +22,7 @@ public function output(array $tree): array
22
22
{
23
23
$ output = [];
24
24
25
- $ stub = $ this ->files ->get ( STUBS_PATH . ' / model/class.stub ' );
25
+ $ stub = $ this ->files ->stub ( ' model/class.stub ' );
26
26
27
27
/** @var \Blueprint\Models\Model $model */
28
28
foreach ($ tree ['models ' ] as $ model ) {
@@ -59,19 +59,19 @@ private function buildProperties(Model $model)
59
59
60
60
$ columns = $ this ->fillableColumns ($ model ->columns ());
61
61
if (!empty ($ columns )) {
62
- $ properties .= PHP_EOL . str_replace ('[] ' , $ this ->pretty_print_array ($ columns , false ), $ this ->getStub ( ' fillable ' ));
62
+ $ properties .= PHP_EOL . str_replace ('[] ' , $ this ->pretty_print_array ($ columns , false ), $ this ->files -> stub ( ' model/ fillable.stub ' ));
63
63
} else {
64
- $ properties .= $ this ->getStub ( ' fillable ' );
64
+ $ properties .= $ this ->files -> stub ( ' model/ fillable.stub ' );
65
65
}
66
66
67
67
$ columns = $ this ->castableColumns ($ model ->columns ());
68
68
if (!empty ($ columns )) {
69
- $ properties .= PHP_EOL . str_replace ('[] ' , $ this ->pretty_print_array ($ columns ), $ this ->getStub ( ' casts ' ));
69
+ $ properties .= PHP_EOL . str_replace ('[] ' , $ this ->pretty_print_array ($ columns ), $ this ->files -> stub ( ' model/ casts.stub ' ));
70
70
}
71
71
72
72
$ columns = $ this ->dateColumns ($ model ->columns ());
73
73
if (!empty ($ columns )) {
74
- $ properties .= PHP_EOL . str_replace ('[] ' , $ this ->pretty_print_array ($ columns , false ), $ this ->getStub ( ' dates ' ));
74
+ $ properties .= PHP_EOL . str_replace ('[] ' , $ this ->pretty_print_array ($ columns , false ), $ this ->files -> stub ( ' model/ dates.stub ' ));
75
75
}
76
76
77
77
return trim ($ properties );
@@ -88,7 +88,7 @@ private function buildRelationships(Model $model)
88
88
}
89
89
90
90
$ methods = '' ;
91
- $ template = $ this ->getStub ( ' method ' );
91
+ $ template = $ this ->files -> stub ( ' model/ method.stub ' );
92
92
93
93
/** @var Column $column */
94
94
foreach ($ columns as $ column ) {
@@ -177,17 +177,6 @@ private function pretty_print_array(array $data, $assoc = true)
177
177
return trim ($ output );
178
178
}
179
179
180
- private function getStub (string $ stub )
181
- {
182
- static $ stubs = [];
183
-
184
- if (empty ($ stubs [$ stub ])) {
185
- $ stubs [$ stub ] = $ this ->files ->get (STUBS_PATH . '/model/ ' . $ stub . '.stub ' );
186
- }
187
-
188
- return $ stubs [$ stub ];
189
- }
190
-
191
180
private function addTraits (Model $ model , $ stub )
192
181
{
193
182
if (!$ model ->usesSoftDeletes ()) {
0 commit comments