改名
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Annotation\Model;
|
||||
|
||||
|
||||
use Annotation\Attribute;
|
||||
use Database\ActiveRecord;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
|
||||
|
||||
/**
|
||||
* Class Relation
|
||||
* @package Annotation\Model
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_METHOD)] class Relation extends Attribute
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Relation constructor.
|
||||
* @param string $name
|
||||
*/
|
||||
public function __construct(public string $name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $handler
|
||||
* @return mixed
|
||||
*/
|
||||
#[Pure] public function execute(array $handler): mixed
|
||||
{
|
||||
// /** @var ActiveRecord $activeRecord */
|
||||
// [$activeRecord, $method] = $handler;
|
||||
//
|
||||
// $activeRecord->setRelate($this->name, $method);
|
||||
|
||||
return parent::execute($handler);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -227,10 +227,10 @@ class ActiveQuery extends Component implements ISqlBuilder
|
||||
|
||||
|
||||
/**
|
||||
* @param $model
|
||||
* @return mixed
|
||||
* @param ActiveRecord $model
|
||||
* @return ActiveRecord
|
||||
*/
|
||||
public function getWith($model): mixed
|
||||
public function getWith(ActiveRecord $model): ActiveRecord
|
||||
{
|
||||
if (empty($this->with) || !is_array($this->with)) {
|
||||
return $model;
|
||||
|
||||
@@ -11,7 +11,6 @@ namespace Database\Base;
|
||||
|
||||
|
||||
use Annotation\Event;
|
||||
use Annotation\IAnnotation;
|
||||
use Annotation\Inject;
|
||||
use Annotation\Model\Get;
|
||||
use Annotation\Model\Set;
|
||||
@@ -55,6 +54,9 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
||||
protected ?SEvent $event;
|
||||
|
||||
|
||||
protected array $_with = [];
|
||||
|
||||
|
||||
/** @var array */
|
||||
protected array $_attributes = [];
|
||||
|
||||
@@ -658,6 +660,17 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess
|
||||
$this->_relate[$name] = $value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @return bool
|
||||
*/
|
||||
public function hasRelate($name): bool
|
||||
{
|
||||
return isset($this->_relate[$name]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $relates
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user