Skip to content

Commit 1d6340c

Browse files
committed
feat: Added Options to AttributeTableWriter
1 parent 240e0dd commit 1d6340c

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

WebFiori/Framework/Writers/AttributeTableWriter.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ public function writeClassComment() {
5555

5656
// Add Column attributes
5757
foreach ($this->columns as $col) {
58-
$attr = "#[Column(name: '{$col['name']}', type: DataType::{$col['type']}";
58+
$type = strtoupper($col['type']);
59+
$attr = "#[Column(name: '{$col['name']}', type: DataType::{$type}";
5960

6061
if (isset($col['size'])) {
6162
$attr .= ", size: {$col['size']}";
@@ -69,7 +70,18 @@ public function writeClassComment() {
6970
if (isset($col['nullable']) && $col['nullable']) {
7071
$attr .= ", nullable: true";
7172
}
72-
73+
if (isset($col['identity']) && $col['identity']) {
74+
$attr .= ", identity: true";
75+
}
76+
if (isset($col['autoUpdate']) && $col['autoUpdate']) {
77+
$attr .= ", autoUpdate: true";
78+
}
79+
if (isset($col['default'])) {
80+
$attr .= ", default: ".$col['default'];
81+
}
82+
if (isset($col['comment']) && strlen($col['comment']) != 0) {
83+
$attr .= ", comment: ".$col['comment'];
84+
}
7385
$attr .= ')]';
7486
$this->append($attr, 0);
7587
}

0 commit comments

Comments
 (0)