Bicycle/App/Repositories/TransactionHistoryRepository.php
2026-08-15 19:40:29 +03:00

46 lines
1.7 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* @package Bicycle
* @author Egor Isaev
* @description TransactionHistoryRepository.php
* @copyright (c) 15/08/2026
*/
namespace App\Repositories;
use System\Classes\Repository;
/**
* Репозиторий таблицы transaction_history — лог правок/удалений операций (см.
* бюджет_текущий_план.md → Transactions → «Лог правок/удалений»). Только запись — само чтение
* лога/механизм отката не спроектированы, здесь только то, что нужно, чтобы лог начал
* наполняться вместе с CRUD транзакций (App\Controller\TransactionsController).
*/
class TransactionHistoryRepository extends Repository
{
/**
* @param string|null $connection Имя подключения (Database::instance($connection)); null — по умолчанию
*/
public function __construct(?string $connection = null)
{
parent::__construct('transaction_history', connection: $connection);
}
/**
* @param int $transaction_id
* @param int $user_id
* @param string $action create|edit|delete
* @param array|null $snapshot Полный слепок строки transactions после действия; null для delete
* @return void
*/
public function log(int $transaction_id, int $user_id, string $action, ?array $snapshot): void
{
$this->create([
'transaction_id' => $transaction_id,
'user_id' => $user_id,
'action' => $action,
'snapshot' => $snapshot,
]);
}
}