@@ -39,7 +39,7 @@ private function writeFunction(string $functionStub, string $functionName, strin
39
39
$ columnName = str_plural (camel_case ($ columnName ));
40
40
} elseif ($ functionName === 'create ' ) {
41
41
$ functionReturnType = $ attributeType ;
42
- } elseif ($ functionName === 'update ' ) {
42
+ } elseif (in_array ( $ functionName, [ 'update ' , ' remove ' , ' restore ' ]) ) {
43
43
$ functionReturnType = 'int ' ;
44
44
}
45
45
@@ -145,6 +145,15 @@ public function handle(): int
145
145
$ this ->writeFunction ($ functionStub , 'update ' , $ entityVariableName , $ entityName ),
146
146
-1 , 0 );
147
147
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
+
148
157
$ baseContent = str_replace (['{{ Attributes }} ' , '{{ Setters }} ' , '{{ Functions }} ' , '{{ EntityName }} ' , '{{ EntityNamespace }} ' , '{{ FactoryName }} ' , '{{ FactoryNamespace }} ' , '{{ EntityVariableName }} ' , '{{ RepositoryName }} ' , '{{ SqlRepositoryName }} ' , '{{ SqlRepositoryVariable }} ' , '{{ RepositoryNamespace }} ' , '{{ RepositoryInterfaceName }} ' , '{{ TableName }} ' ],
149
158
[$ attributes , $ setters , $ functions , $ entityName , $ entityNamespace , $ factoryName , $ factoryNamespace , $ entityVariableName , $ repositoryName , $ sqlRepositoryName , $ sqlRepositoryVariable , $ repositoryNamespace , $ interfaceName , $ tableName ],
150
159
$ baseContent );
0 commit comments