46 lines
1.2 KiB
PHP
46 lines
1.2 KiB
PHP
<?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,
|
||
]);
|
||
}
|
||
}
|