2022-01-09 03:49:51 +08:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Created by PhpStorm.
|
|
|
|
|
* User: whwyy
|
|
|
|
|
* Date: 2018/4/4 0004
|
|
|
|
|
* Time: 13:58
|
|
|
|
|
*/
|
|
|
|
|
declare(strict_types=1);
|
2022-01-19 14:59:46 +08:00
|
|
|
|
2022-01-09 03:49:51 +08:00
|
|
|
namespace Database;
|
|
|
|
|
|
|
|
|
|
use Database\Traits\HasBase;
|
2022-01-19 14:59:46 +08:00
|
|
|
use Exception;
|
2022-01-09 03:49:51 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class HasMany
|
|
|
|
|
* @package Database
|
|
|
|
|
*
|
|
|
|
|
* @method with($name)
|
|
|
|
|
*/
|
|
|
|
|
class HasMany extends HasBase
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
2022-04-28 03:24:58 +08:00
|
|
|
* @return array|null|Collection
|
2022-01-09 03:49:51 +08:00
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
2022-04-28 03:24:58 +08:00
|
|
|
public function get(): array|Collection|null
|
2022-01-09 03:49:51 +08:00
|
|
|
{
|
2022-09-29 18:58:32 +08:00
|
|
|
$key = $this->model::className() . '_' . $this->primaryId . '_' . $this->value;
|
2022-09-29 22:51:41 +08:00
|
|
|
return $this->_relation->get(md5($key));
|
2022-01-09 03:49:51 +08:00
|
|
|
}
|
|
|
|
|
}
|