@@ -39,7 +39,7 @@ private function writeFunction(string $functionStub, string $functionName, strin
3939 $ columnName = str_plural (camel_case ($ columnName ));
4040 } elseif ($ functionName === 'create ' ) {
4141 $ functionReturnType = $ attributeType ;
42- } elseif ($ functionName === 'update ' ) {
42+ } elseif (in_array ( $ functionName, [ 'update ' , ' remove ' , ' restore ' ]) ) {
4343 $ functionReturnType = 'int ' ;
4444 }
4545
@@ -145,6 +145,15 @@ public function handle(): int
145145 $ this ->writeFunction ($ functionStub , 'update ' , $ entityVariableName , $ entityName ),
146146 -1 , 0 );
147147
148+ if (in_array ('deleted_at ' , $ columns ->pluck ('COLUMN_NAME ' )->toArray (), true )) {
149+ $ functions = substr_replace ($ functions ,
150+ $ this ->writeFunction ($ functionStub , 'remove ' , $ entityVariableName , $ entityName ),
151+ -1 , 0 );
152+ $ functions = substr_replace ($ functions ,
153+ $ this ->writeFunction ($ functionStub , 'restore ' , $ entityVariableName , $ entityName ),
154+ -1 , 0 );
155+ }
156+
148157 $ baseContent = str_replace (['{{ Attributes }} ' , '{{ Setters }} ' , '{{ Functions }} ' , '{{ EntityName }} ' , '{{ EntityNamespace }} ' , '{{ FactoryName }} ' , '{{ FactoryNamespace }} ' , '{{ EntityVariableName }} ' , '{{ RepositoryName }} ' , '{{ SqlRepositoryName }} ' , '{{ SqlRepositoryVariable }} ' , '{{ RepositoryNamespace }} ' , '{{ RepositoryInterfaceName }} ' , '{{ TableName }} ' ],
149158 [$ attributes , $ setters , $ functions , $ entityName , $ entityNamespace , $ factoryName , $ factoryNamespace , $ entityVariableName , $ repositoryName , $ sqlRepositoryName , $ sqlRepositoryVariable , $ repositoryNamespace , $ interfaceName , $ tableName ],
150159 $ baseContent );
0 commit comments