Skip to content

Commit 4e59112

Browse files
committed
Fix MakeEntity Command to Properly Add Entity Attributes
1 parent 9aafe88 commit 4e59112

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

src/Commands/MakeEntity.php

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -103,34 +103,42 @@ public function handle(): int
103103
// Create Attributes
104104
$attributes = '';
105105
foreach ($columns as $_column) {
106-
$attributes = substr_replace($attributes,
107-
$this->writeAttribute($attributeStub, $_column->COLUMN_NAME, ($_column->IS_NULLABLE === 'YES' ? '?' : '') . $this->dataTypes[$_column->DATA_TYPE]),
108-
-1, 0);
106+
$attributes .= $this->writeAttribute(
107+
$attributeStub,
108+
$_column->COLUMN_NAME,
109+
($_column->IS_NULLABLE === 'YES' ? '?' : '') . $this->dataTypes[$_column->DATA_TYPE]
110+
);
109111
}
110112

111113
// Create Setters and Getters
112114
$settersAndGetters = '';
113115
foreach ($columns as $_column) {
114-
$settersAndGetters = substr_replace($settersAndGetters,
115-
$this->writeAccessors($accessorsStub, $_column->COLUMN_NAME, ($_column->IS_NULLABLE === 'YES' ? '?' : '') . $this->dataTypes[$_column->DATA_TYPE]),
116-
-1, 0);
116+
$settersAndGetters .= $this->writeAccessors(
117+
$accessorsStub,
118+
$_column->COLUMN_NAME,
119+
($_column->IS_NULLABLE === 'YES' ? '?' : '') . $this->dataTypes[$_column->DATA_TYPE]
120+
);
117121
}
118122

119123
if ($detectForeignKeys) {
120124
$foreignKeys = $this->extractForeignKeys($tableName);
121125

122126
// Create Additional Attributes from Foreign Keys
123127
foreach ($foreignKeys as $_foreignKey) {
124-
$attributes = substr_replace($attributes,
125-
$this->writeAttribute($attributeStub, $_foreignKey->VARIABLE_NAME, $_foreignKey->ENTITY_DATA_TYPE),
126-
-1, 0);
128+
$attributes .= $this->writeAttribute(
129+
$attributeStub,
130+
$_foreignKey->VARIABLE_NAME,
131+
$_foreignKey->ENTITY_DATA_TYPE
132+
);
127133
}
128134

129135
// Create Additional Setters and Getters from Foreign keys
130136
foreach ($foreignKeys as $_foreignKey) {
131-
$settersAndGetters = substr_replace($settersAndGetters,
132-
$this->writeAccessors($accessorsStub, $_foreignKey->VARIABLE_NAME, $_foreignKey->ENTITY_DATA_TYPE),
133-
-1, 0);
137+
$settersAndGetters .= $this->writeAccessors(
138+
$accessorsStub,
139+
$_foreignKey->VARIABLE_NAME,
140+
$_foreignKey->ENTITY_DATA_TYPE
141+
);
134142
}
135143
}
136144

@@ -148,4 +156,4 @@ public function handle(): int
148156

149157
return 0;
150158
}
151-
}
159+
}

0 commit comments

Comments
 (0)