2022-01-09 03:49:51 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Database\Annotation;
|
|
|
|
|
|
|
|
|
|
|
2022-02-23 16:32:08 +08:00
|
|
|
use Kiri\Annotation\AbstractAttribute;
|
2022-01-09 03:49:51 +08:00
|
|
|
use Database\Base\Relate;
|
|
|
|
|
use Exception;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class Relation
|
|
|
|
|
* @package Annotation\Model
|
|
|
|
|
*/
|
2022-02-23 16:32:08 +08:00
|
|
|
#[\Attribute(\Attribute::TARGET_METHOD)] class Relation extends AbstractAttribute
|
2022-01-09 03:49:51 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Relation constructor.
|
|
|
|
|
* @param string $name
|
|
|
|
|
*/
|
|
|
|
|
public function __construct(public string $name)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param mixed $class
|
|
|
|
|
* @param mixed|null $method
|
|
|
|
|
* @return bool
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public function execute(mixed $class, mixed $method = null): bool
|
|
|
|
|
{
|
|
|
|
|
di(Relate::class)->addRelate($this->name, $class, $method);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|