Bicycle/App/Controller/TransactionsController.php
2026-08-15 10:39:22 +03:00

46 lines
1.2 KiB
PHP
Raw 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 TransactionsController.php
* @copyright (c) 14/08/2026
*/
namespace App\Controller;
use App\Repositories\TransactionRepository;
use App\Repositories\UserRepository;
use Services\Auth;
use System\Classes\Controller;
use System\Classes\HTTP\HTTPException;
use System\Classes\MyException;
/**
* Список транзакций пользователя — последние 50, с категорией и счётом.
*/
class TransactionsController extends Controller
{
protected bool $_auth_protection = true;
/**
* @return string
* @throws HTTPException|MyException
*/
public function indexAction(): string
{
$auth_user = Auth::instance()->getUser();
$user = (new UserRepository())->getByLogin($auth_user['login']);
if (!$user) {
throw HTTPException::factory(404);
}
$transactions = (new TransactionRepository())->getRecentForUser($user->id, 50);
return $this->render('index', [
'user' => $auth_user,
'transactions' => $transactions,
]);
}
}