summaryrefslogtreecommitdiff
path: root/src/application/mystic/forum/attributes
diff options
context:
space:
mode:
authorJonas Kohl2024-09-12 19:49:17 +0200
committerJonas Kohl2024-09-12 19:49:17 +0200
commit086e2d2668784469ec114f6e6fd2b3dace3d7c3b (patch)
treeb9bacedb713501d88d24085940267a7c94e69b29 /src/application/mystic/forum/attributes
parent34b1b391d4b03659a96f868857c230002b351514 (diff)
Way more progress on forum
Diffstat (limited to 'src/application/mystic/forum/attributes')
-rw-r--r--src/application/mystic/forum/attributes/DefaultValue.php10
-rw-r--r--src/application/mystic/forum/attributes/References.php14
-rw-r--r--src/application/mystic/forum/attributes/Unique.php6
3 files changed, 28 insertions, 2 deletions
diff --git a/src/application/mystic/forum/attributes/DefaultValue.php b/src/application/mystic/forum/attributes/DefaultValue.php
new file mode 100644
index 0000000..e3dd1a5
--- /dev/null
+++ b/src/application/mystic/forum/attributes/DefaultValue.php
@@ -0,0 +1,10 @@
+<?php
+
+namespace mystic\forum\attributes;
+
+#[\Attribute(\Attribute::TARGET_PROPERTY)]
+class DefaultValue {
+ public function __construct(
+ public readonly string $defaultValue,
+ ) {}
+}
diff --git a/src/application/mystic/forum/attributes/References.php b/src/application/mystic/forum/attributes/References.php
index 9e33927..8271ebb 100644
--- a/src/application/mystic/forum/attributes/References.php
+++ b/src/application/mystic/forum/attributes/References.php
@@ -4,15 +4,25 @@ namespace mystic\forum\attributes;
#[\Attribute(\Attribute::TARGET_PROPERTY)]
class References {
+ public const NO_ACTION = 0;
+ public const CASCADE = 1;
+ public const SET_NULL = 2;
+ public const SET_DEFAULT = 3;
+
public function __construct(
public readonly string $foreignTableName,
public readonly ?string $foreignColumnName = null,
- public readonly bool $cascadeOnDelete = false,
+ public readonly int $onDelete = self::NO_ACTION,
) {}
public function __toString(): string {
return $this->foreignTableName
. ($this->foreignColumnName !== null ? " ({$this->foreignColumnName})" : "")
- . ($this->cascadeOnDelete ? " ON DELETE CASCADE" : "");
+ . ([
+ self::NO_ACTION => "",
+ self::CASCADE => " ON DELETE CASCADE",
+ self::SET_NULL => " ON DELETE SET NULL",
+ self::SET_DEFAULT => " ON DELETE SET DEFAULT",
+ ][$this->onDelete] ?? "");
}
}
diff --git a/src/application/mystic/forum/attributes/Unique.php b/src/application/mystic/forum/attributes/Unique.php
new file mode 100644
index 0000000..7c32255
--- /dev/null
+++ b/src/application/mystic/forum/attributes/Unique.php
@@ -0,0 +1,6 @@
+<?php
+
+namespace mystic\forum\attributes;
+
+#[\Attribute(\Attribute::TARGET_PROPERTY)]
+class Unique {}