Skip to content

Commit 1b2199e

Browse files
committed
Detect Nullable Attributes for Making Entities
1 parent 5a0d3cd commit 1b2199e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Commands/MakeEntity.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ public function handle(): int
104104
$attributes = '';
105105
foreach ($columns as $_column) {
106106
$attributes = substr_replace($attributes,
107-
$this->writeAttribute($attributeStub, $_column->COLUMN_NAME, $this->dataTypes[$_column->DATA_TYPE]),
107+
$this->writeAttribute($attributeStub, $_column->COLUMN_NAME, ($_column->IS_NULLABLE === 'YES' ? '?' : '') . $this->dataTypes[$_column->DATA_TYPE]),
108108
-1, 0);
109109
}
110110

111111
// Create Setters and Getters
112112
$settersAndGetters = '';
113113
foreach ($columns as $_column) {
114114
$settersAndGetters = substr_replace($settersAndGetters,
115-
$this->writeAccessors($accessorsStub, $_column->COLUMN_NAME, $this->dataTypes[$_column->DATA_TYPE]),
115+
$this->writeAccessors($accessorsStub, $_column->COLUMN_NAME, ($_column->IS_NULLABLE === 'YES' ? '?' : '') . $this->dataTypes[$_column->DATA_TYPE]),
116116
-1, 0);
117117
}
118118

0 commit comments

Comments
 (0)