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;
|
2023-04-01 17:11:47 +08:00
|
|
|
use Kiri;
|
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
|
|
|
{
|
2023-04-01 17:11:47 +08:00
|
|
|
$relation = Kiri::getDi()->get(Relation::class);
|
2023-04-01 18:50:44 +08:00
|
|
|
return $relation->getQuery($this->name)->get();
|
2022-01-09 03:49:51 +08:00
|
|
|
}
|
|
|
|
|
}
|