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\Http\Requests\AccountFormRequest;
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||||
|
use Illuminate\Pagination\LengthAwarePaginator;
|
||||||
use Input;
|
use Input;
|
||||||
use Redirect;
|
use Redirect;
|
||||||
use Session;
|
use Session;
|
||||||
use View;
|
|
||||||
use Steam;
|
use Steam;
|
||||||
|
use View;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AccountController
|
* Class AccountController
|
||||||
@ -117,16 +118,21 @@ class AccountController extends Controller
|
|||||||
$subTitle = Config::get('firefly.subTitlesByIdentifier.' . $what);
|
$subTitle = Config::get('firefly.subTitlesByIdentifier.' . $what);
|
||||||
$subTitleIcon = Config::get('firefly.subIconsByIdentifier.' . $what);
|
$subTitleIcon = Config::get('firefly.subIconsByIdentifier.' . $what);
|
||||||
$types = Config::get('firefly.accountTypesByIdentifier.' . $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:
|
// move to repository:
|
||||||
$accounts = Auth::user()->accounts()->with(
|
$set = Auth::user()->accounts()->with(
|
||||||
['accountmeta' => function ($query) {
|
['accountmeta' => function ($query) {
|
||||||
$query->where('name', 'accountRole');
|
$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:
|
// last activity:
|
||||||
$accounts->each(
|
$set->each(
|
||||||
function (Account $account) {
|
function (Account $account) {
|
||||||
$lastTransaction = $account->transactions()->leftJoin(
|
$lastTransaction = $account->transactions()->leftJoin(
|
||||||
'transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id'
|
'transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id'
|
||||||
@ -137,10 +143,13 @@ class AccountController extends Controller
|
|||||||
$account->lastActivityDate = null;
|
$account->lastActivityDate = null;
|
||||||
}
|
}
|
||||||
$account->startBalance = Steam::balance($account, Session::get('start'));
|
$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'));
|
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">
|
<table class="table table-striped">
|
||||||
<tr>
|
<tr>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
@ -51,3 +54,6 @@
|
|||||||
|
|
||||||
@endforeach
|
@endforeach
|
||||||
</table>
|
</table>
|
||||||
|
@if(is_object($accounts) && method_exists($accounts, 'render'))
|
||||||
|
{!! $accounts->render() !!}
|
||||||
|
@endif
|
Loading…
Reference in New Issue
Block a user