@@ -144,7 +144,7 @@ protected function generateResource(Model $model): void
144
144
{
145
145
$ class = get_class ($ model );
146
146
$ name = class_basename ($ class );
147
- $ path = $ this ->dir . '/ ' . $ name . '.php ' ;
147
+ $ path = $ this ->dir . '/ ' . $ name . 'Resource ' . ' .php ' ;
148
148
149
149
if ($ this ->files ->exists ($ path )) {
150
150
$ this ->error ("API Resource for $ class already exists! " );
@@ -165,13 +165,19 @@ protected function buildResource(string $class, string $name): string
165
165
$ properties = $ this ->properties ;
166
166
$ fields = '' ;
167
167
168
+ $ properties_length = count ($ properties );
169
+ $ count = 0 ;
168
170
foreach ($ properties as $ property ) {
169
- $ fields .= "\t\t\t' $ property' => \$this-> $ property, \n" ;
171
+ if ($ count < $ properties_length - 1 ) {
172
+ $ fields .= "' $ property' => \$this-> $ property, \n" ;
173
+ } else {
174
+ $ fields .= "' $ property' => \$this-> $ property " ;
175
+ }
170
176
}
171
177
172
178
$ stub = $ this ->files ->get ($ this ->stub );
173
179
174
- $ stub = str_replace ('{{ class }} ' , $ name , $ stub );
180
+ $ stub = str_replace ('{{ class }} ' , $ name . ' Resource ' , $ stub );
175
181
$ stub = str_replace ('{{ namespace }} ' , $ this ->namespace , $ stub );
176
182
return str_replace ('{{ fields }} ' , $ fields , $ stub );
177
183
}
0 commit comments