37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
<?php
|
||
/**
|
||
* @package Bicycle
|
||
* @author Egor Isaev
|
||
* @description AccountRateRepository.php
|
||
* @copyright (c) 11/08/2026
|
||
*/
|
||
|
||
namespace App\Repositories;
|
||
|
||
use System\Classes\Repository;
|
||
|
||
/**
|
||
* Репозиторий таблицы account_rates (история процентных ставок savings-счёта).
|
||
*/
|
||
class AccountRateRepository extends Repository
|
||
{
|
||
/**
|
||
* @param string|null $connection Имя подключения (Database::instance($connection)); null — по умолчанию
|
||
*/
|
||
public function __construct(?string $connection = null)
|
||
{
|
||
parent::__construct('account_rates', connection: $connection);
|
||
}
|
||
|
||
/**
|
||
* Текущая ставка счёта (запись с valid_to IS NULL — см. бюджет_текущий_план.md).
|
||
*
|
||
* @param int $account_id
|
||
* @return object|false|null Строка account_rates | false, если не найдено | null (не бывает — $where не пуст)
|
||
*/
|
||
public function getCurrentRate(int $account_id): mixed
|
||
{
|
||
return $this->getItemWhere("account_id = $account_id AND valid_to IS NULL");
|
||
}
|
||
}
|