mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-07 06:33:57 -06:00
43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?php
|
|
use Firefly\Helper\Preferences\PreferencesHelperInterface as PHI;
|
|
use Firefly\Storage\Account\AccountRepositoryInterface as ARI;
|
|
use Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface as TJRI;
|
|
|
|
|
|
class HomeController extends BaseController
|
|
{
|
|
protected $accounts;
|
|
protected $preferences;
|
|
protected $tj;
|
|
|
|
public function __construct(ARI $accounts, PHI $preferences, TJRI $tj)
|
|
{
|
|
$this->accounts = $accounts;
|
|
$this->preferences = $preferences;
|
|
$this->tj = $tj;
|
|
View::share('menu', 'home');
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
// get list setting:
|
|
$pref = $this->preferences->get('frontpageAccounts', []);
|
|
|
|
// get the accounts to display on the home screen:
|
|
$count = $this->accounts->count();
|
|
if ($pref->data == []) {
|
|
$list = $this->accounts->getActiveDefault();
|
|
} else {
|
|
$list = $this->accounts->getByIds($pref->data);
|
|
}
|
|
|
|
// get transactions for each account:
|
|
foreach ($list as $account) {
|
|
$account->transactionList = $this->tj->getByAccount($account,10);
|
|
}
|
|
|
|
|
|
// build the home screen:
|
|
return View::make('index')->with('count', $count)->with('accounts', $list);
|
|
}
|
|
} |