@@ -161,26 +161,27 @@ protected function replaceSetFromDb(&$stub, $name)
161161 }
162162
163163 $ attributes = $ this ->getAttributes ($ model );
164+ $ fields = array_diff ($ attributes , ['id ' , 'created_at ' , 'updated_at ' , 'deleted_at ' ]);
165+ $ columns = array_diff ($ attributes , ['id ' ]);
166+ $ glue = PHP_EOL .' ' ;
164167
165168 // create an array with the needed code for defining fields
166- $ fields = Arr::except ($ attributes , ['id ' , 'created_at ' , 'updated_at ' , 'deleted_at ' ]);
167169 $ fields = collect ($ fields )
168170 ->map (function ($ field ) {
169171 return "CRUD::field(' $ field'); " ;
170172 })
171- ->toArray ( );
173+ ->join ( $ glue );
172174
173175 // create an array with the needed code for defining columns
174- $ columns = Arr::except ($ attributes , ['id ' ]);
175176 $ columns = collect ($ columns )
176177 ->map (function ($ column ) {
177178 return "CRUD::column(' $ column'); " ;
178179 })
179- ->toArray ( );
180+ ->join ( $ glue );
180181
181182 // replace setFromDb with actual fields and columns
182- $ stub = str_replace ('CRUD::setFromDb(); // fields ' , implode ( PHP_EOL . ' ' , $ fields) , $ stub );
183- $ stub = str_replace ('CRUD::setFromDb(); // columns ' , implode ( PHP_EOL . ' ' , $ columns) , $ stub );
183+ $ stub = str_replace ('CRUD::setFromDb(); // fields ' , $ fields , $ stub );
184+ $ stub = str_replace ('CRUD::setFromDb(); // columns ' , $ columns , $ stub );
184185
185186 return $ this ;
186187 }
0 commit comments