ulmus/src/Attribute/Property/Field/ForeignKey.php

33 lines
1.1 KiB
PHP

<?php
namespace Ulmus\Attribute\Property\Field;
use Ulmus\Attribute\Attribute;
use Ulmus\Attribute\ConstrainActionEnum;
/**
* Since we need consistancy between the declaration of our ID and FK fields, it
* was decided to extend the PK class instead of Field for this case.
*/
#[\Attribute(\Attribute::TARGET_PROPERTY)]
class ForeignKey extends PrimaryKey {
public function __construct(
public ? string $name = null,
public ? string $type = null,
public null|int|string $length = null,
public ? int $precision = null,
public array $attributes = [
'primary_key' => false,
'auto_increment' => false
],
public bool $nullable = false,
public mixed $default = null,
public bool $readonly = false,
public null|string $relation = null,
public ConstrainActionEnum $onDelete = ConstrainActionEnum::NoAction,
public ConstrainActionEnum $onUpdate = ConstrainActionEnum::NoAction,
) {
#$this->references = Attribute::handleArrayField($this->references, false);
}
}