mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-29 02:11:12 -06:00
Paginated the account list.
This commit is contained in:
parent
08ca3c89d3
commit
14c7ad201a
@ -8,11 +8,12 @@ use FireflyIII\Http\Requests;
|
||||
use FireflyIII\Http\Requests\AccountFormRequest;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Input;
|
||||
use Redirect;
|
||||
use Session;
|
||||
use View;
|
||||
use Steam;
|
||||
use View;
|
||||
|
||||
/**
|
||||
* Class AccountController
|
||||
@ -117,16 +118,21 @@ class AccountController extends Controller
|
||||
$subTitle = Config::get('firefly.subTitlesByIdentifier.' . $what);
|
||||
$subTitleIcon = Config::get('firefly.subIconsByIdentifier.' . $what);
|
||||
$types = Config::get('firefly.accountTypesByIdentifier.' . $what);
|
||||
$size = 50;
|
||||
$page = intval(Input::get('page')) == 0 ? 1 : intval(Input::get('page'));
|
||||
$offset = ($page - 1) * $size;
|
||||
|
||||
|
||||
// move to repository:
|
||||
$accounts = Auth::user()->accounts()->with(
|
||||
$set = Auth::user()->accounts()->with(
|
||||
['accountmeta' => function ($query) {
|
||||
$query->where('name', 'accountRole');
|
||||
}]
|
||||
)->accountTypeIn($types)->get(['accounts.*']);
|
||||
)->accountTypeIn($types)->take($size)->offset($offset)->get(['accounts.*']);
|
||||
$total = Auth::user()->accounts()->accountTypeIn($types)->count();
|
||||
|
||||
// last activity:
|
||||
$accounts->each(
|
||||
$set->each(
|
||||
function (Account $account) {
|
||||
$lastTransaction = $account->transactions()->leftJoin(
|
||||
'transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id'
|
||||
@ -137,10 +143,13 @@ class AccountController extends Controller
|
||||
$account->lastActivityDate = null;
|
||||
}
|
||||
$account->startBalance = Steam::balance($account, Session::get('start'));
|
||||
$account->endBalance = Steam::balance($account, Session::get('end'));
|
||||
$account->endBalance = Steam::balance($account, Session::get('end'));
|
||||
}
|
||||
);
|
||||
|
||||
$accounts = new LengthAwarePaginator($set, $total, $size, $page);
|
||||
$accounts->setPath(route('accounts.index',$what));
|
||||
|
||||
|
||||
return view('accounts.index', compact('what', 'subTitleIcon', 'subTitle', 'accounts'));
|
||||
}
|
||||
|
@ -1,3 +1,6 @@
|
||||
@if(is_object($accounts) && method_exists($accounts, 'render'))
|
||||
{!! $accounts->render() !!}
|
||||
@endif
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th> </th>
|
||||
@ -51,3 +54,6 @@
|
||||
|
||||
@endforeach
|
||||
</table>
|
||||
@if(is_object($accounts) && method_exists($accounts, 'render'))
|
||||
{!! $accounts->render() !!}
|
||||
@endif
|
Loading…
Reference in New Issue
Block a user