- WIP on relations, constrains and foreign keys
This commit is contained in:
1 parent
01ab6e82d4
commit
d01624b8aa
8 files changed
+90
-30
No files matched your search
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Ulmus\Attribute\Obj;
|
||||
|
||||
use Ulmus\Attribute\Attribute;
|
||||
use Ulmus\Attribute\ConstrainActionEnum;
|
||||
use Ulmus\Attribute\IndexTypeEnum;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
|
||||
class Constrain {
|
||||
public function __construct(
|
||||
public array $columns,
|
||||
public null|IndexTypeEnum $type = null,
|
||||
public null|string $name = null,
|
||||
public null|array|string|\Stringable $foreignKey = null,
|
||||
public null|array|string|\Stringable $references = null,
|
||||
public ConstrainActionEnum $onDelete = ConstrainActionEnum::NoAction,
|
||||
public ConstrainActionEnum $onUpdate = ConstrainActionEnum::NoAction,
|
||||
) {
|
||||
$this->foreignKey = Attribute::handleArrayField($this->foreignKey, false);
|
||||
$this->references = Attribute::handleArrayField($this->references, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Ulmus\Attribute\Obj;
|
||||
|
||||
use Ulmus\Attribute\IndexTypeEnum;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
|
||||
class Index {
|
||||
public function __construct(
|
||||
public string|array $column,
|
||||
public IndexTypeEnum $type = IndexTypeEnum::Unique,
|
||||
public null|string $name = null,
|
||||
) {}
|
||||
}
|
||||
Reference in new issue
Block a user