Files
kiri-databases/src/Annotation/Relation.php
T

43 lines
706 B
PHP
Raw Normal View History

2021-08-17 16:22:18 +08:00
<?php
namespace Database\Annotation;
use Annotation\Attribute;
use Database\Base\Relate;
use Exception;
/**
* Class Relation
* @package Annotation\Model
*/
#[\Attribute(\Attribute::TARGET_METHOD)] class Relation extends Attribute
{
2021-08-29 04:06:48 +08:00
/**
* Relation constructor.
* @param string $name
*/
2021-08-29 05:53:45 +08:00
public function __construct(public string $name)
2021-08-29 04:06:48 +08:00
{
}
/**
* @param static $params
* @param mixed $class
* @param mixed|null $method
* @return bool
* @throws Exception
*/
2021-08-29 05:53:45 +08:00
public function execute(mixed $class, mixed $method = null): bool
2021-08-29 04:06:48 +08:00
{
2021-08-29 05:53:45 +08:00
di(Relate::class)->addRelate($class, $this->name, $method);
2021-08-17 16:22:18 +08:00
return true;
2021-08-29 04:06:48 +08:00
}
2021-08-17 16:22:18 +08:00
}