@@ -153,21 +153,7 @@ private function writeGetAllFunction(string $getOneStub, string $columnName, str
153153 $ getOneStub );
154154 }
155155
156- private function writeGetterFunction (string $ getterStub , string $ columnName ): string
157- {
158- return str_replace (['{{ ColumnName }} ' , '{{ GetterName }} ' ],
159- [$ columnName , ucfirst (Str::camel ($ columnName ))],
160- $ getterStub );
161- }
162-
163- private function writeSetterFunction (string $ setterStub , string $ columnName ): string
164- {
165- return str_replace ('{{ SetterName }} ' ,
166- ucfirst (Str::camel ($ columnName )),
167- $ setterStub );
168- }
169-
170- private function getConstruct (string $ tableName , string $ factoryName , bool $ hasSoftDelete , string $ constructContent )
156+ private function getConstruct (string $ tableName , string $ factoryName , bool $ hasSoftDelete , string $ constructContent )
171157 {
172158 return str_replace (
173159 ['{{ TableName }} ' , '{{ FactoryName }} ' , '{{ HasSoftDelete }} ' ],
@@ -186,11 +172,11 @@ public function makeCreateFunction(array &$stubContent, string &$getterFunctions
186172 {
187173 foreach ($ this ->columns as $ _column ) {
188174 if (!in_array ($ _column ->COLUMN_NAME , ['id ' , 'deleted_at ' ])) {
189- $ getterFunctions .= trim ($ this -> writeGetterFunction ( $ stubContent [ ' getterStub ' ], $ _column ->COLUMN_NAME )) . "\n\t\t\t\t" ;
175+ $ getterFunctions .= trim (str_replace ([ ' {{ ColumnName }} ' , ' {{ AttributeName }} ' ], [ $ _column ->COLUMN_NAME , Str:: camel ( $ _column -> COLUMN_NAME )], $ stubContent [ ' getterStub ' ] )) . "\n\t\t\t\t" ;
190176 }
191177
192178 if (in_array ($ _column ->COLUMN_NAME , ['created_at ' , 'updated_at ' ], true )) {
193- $ setterFunctions .= trim ($ this -> writeSetterFunction ( $ stubContent [ ' setterStub ' ], $ _column ->COLUMN_NAME )) . "\n\t\t" ;
179+ $ setterFunctions .= trim (str_replace ( ' {{ AttributeName }} ' , Str:: camel ( $ _column ->COLUMN_NAME ), $ stubContent [ ' setterStub ' ] )) . "\n\t\t" ;
194180 }
195181 }
196182
@@ -216,11 +202,11 @@ public function makeUpdateFunction(array &$stubContent, string &$getterFunctions
216202 foreach ($ this ->columns as $ _column ) {
217203
218204 if (!in_array ($ _column ->COLUMN_NAME , ['id ' , 'created_at ' , 'deleted_at ' ])) {
219- $ getterFunctions .= trim ($ this -> writeGetterFunction ( $ stubContent [ ' getterStub ' ], $ _column ->COLUMN_NAME )) . "\n\t\t\t\t" ;
205+ $ getterFunctions .= trim (str_replace ([ ' {{ ColumnName }} ' , ' {{ AttributeName }} ' ], [ $ _column ->COLUMN_NAME , Str:: camel ( $ _column -> COLUMN_NAME )], $ stubContent [ ' getterStub ' ])) . "\n\t\t\t\t" ; ;
220206 }
221207
222208 if ($ _column ->COLUMN_NAME === 'updated_at ' ) {
223- $ setterFunctions .= trim ($ this -> writeSetterFunction ( $ stubContent [ ' setterStub ' ], $ _column ->COLUMN_NAME )) . "\n\t\t" ;
209+ $ setterFunctions .= trim (str_replace ( ' {{ AttributeName }} ' , Str:: camel ( $ _column ->COLUMN_NAME ), $ stubContent [ ' setterStub ' ])) . "\n\t\t" ; ;
224210 }
225211 }
226212
0 commit comments