Skip to content

Commit d0e497e

Browse files
committed
fix: set default value for fields based on mysql default
1 parent 0d7c8c0 commit d0e497e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Commands/MakeEntity.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,10 @@ public function handle(): int
104104
// Create Attributes
105105
$attributes = '';
106106
foreach ($columns as $_column) {
107+
$defaultValue = ($_column->COLUMN_DEFAULT ?? 'null') ? ($_column->COLUMN_DEFAULT ?? 'null') : "''";
107108
$attributes .= $this->writeAttribute(
108109
$attributeStub,
109-
$_column->COLUMN_NAME,
110+
$_column->COLUMN_NAME.($_column->IS_NULLABLE === 'YES' ? ' = '.$defaultValue : ''),
110111
($_column->IS_NULLABLE === 'YES' ? 'null|' : '') . $this->dataTypes[$_column->DATA_TYPE]
111112
);
112113
}

0 commit comments

Comments
 (0)