diff --git a/app/controllers/TransactionController.php b/app/controllers/TransactionController.php index 2ddeccb475..edc007129c 100644 --- a/app/controllers/TransactionController.php +++ b/app/controllers/TransactionController.php @@ -111,6 +111,11 @@ class TransactionController extends BaseController } + public function index() { + $transactions = $this->_journal->paginate(25); + return View::make('transactions.index')->with('transactions',$transactions); + } + public function show($journalId) { $journal = $this->_journal->find($journalId); diff --git a/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.php b/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.php index 88209ad9e1..2ebe1d4084 100644 --- a/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.php +++ b/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.php @@ -4,8 +4,6 @@ namespace Firefly\Storage\TransactionJournal; -use Firefly\Exception\FireflyException; - class EloquentTransactionJournalRepository implements TransactionJournalRepositoryInterface { @@ -167,7 +165,7 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito } - public function getByAccountInDateRange(\Account $account, $count = 25,\Carbon\Carbon $start, \Carbon\Carbon $end) + public function getByAccountInDateRange(\Account $account, $count = 25, \Carbon\Carbon $start, \Carbon\Carbon $end) { $accountID = $account->id; $query = \Auth::user()->transactionjournals()->with( @@ -180,8 +178,8 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito ->leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') ->leftJoin('accounts', 'accounts.id', '=', 'transactions.account_id') ->where('accounts.id', $accountID) - ->where('date','>=',$start->format('Y-m-d')) - ->where('date','<=',$end->format('Y-m-d')) + ->where('date', '>=', $start->format('Y-m-d')) + ->where('date', '<=', $end->format('Y-m-d')) ->orderBy('transaction_journals.date', 'DESC') ->orderBy('transaction_journals.id', 'DESC') ->take($count) @@ -189,6 +187,26 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito return $query; } + public function paginate($count = 25) + { + $query = \Auth::user()->transactionjournals()->with( + [ + 'transactions' => function ($q) { + return $q->orderBy('amount', 'ASC'); + }, + 'transactions.account', + 'transactions.account.accounttype', + 'transactioncurrency', + 'transactiontype' + ] + ) + ->orderBy('transaction_journals.date', 'DESC') + ->orderBy('transaction_journals.id', 'DESC') + ->take($count) + ->paginate($count); + return $query; + } + public function getByDateRange(\Carbon\Carbon $start, \Carbon\Carbon $end) { // lets make this simple. diff --git a/app/lib/Firefly/Storage/TransactionJournal/TransactionJournalRepositoryInterface.php b/app/lib/Firefly/Storage/TransactionJournal/TransactionJournalRepositoryInterface.php index 1a314211b2..3ecef61f5a 100644 --- a/app/lib/Firefly/Storage/TransactionJournal/TransactionJournalRepositoryInterface.php +++ b/app/lib/Firefly/Storage/TransactionJournal/TransactionJournalRepositoryInterface.php @@ -11,10 +11,12 @@ interface TransactionJournalRepositoryInterface public function find($journalId); - public function getByAccountInDateRange(\Account $account, $count = 25,\Carbon\Carbon $start, \Carbon\Carbon $end); + public function getByAccountInDateRange(\Account $account, $count = 25, \Carbon\Carbon $start, \Carbon\Carbon $end); public function getByAccountAndDate(\Account $account, \Carbon\Carbon $date); public function getByDateRange(\Carbon\Carbon $start, \Carbon\Carbon $end); + public function paginate($count = 25); + } \ No newline at end of file diff --git a/app/routes.php b/app/routes.php index 4c77fdc87b..50580e697f 100644 --- a/app/routes.php +++ b/app/routes.php @@ -48,6 +48,7 @@ Route::group(['before' => 'auth'], function () { Route::get('/transaction/show/{id}',['uses' => 'TransactionController@show','as' => 'transactions.show']); Route::get('/transaction/edit/{id}',['uses' => 'TransactionController@edit','as' => 'transactions.edit']); Route::get('/transaction/delete/{id}',['uses' => 'TransactionController@delete','as' => 'transactions.delete']); + Route::get('/transactions/index',['uses' => 'TransactionController@index','as' => 'transactions.index']); // migration controller Route::get('/migrate', ['uses' => 'MigrationController@index', 'as' => 'migrate']); diff --git a/app/views/partials/menu/home.blade.php b/app/views/partials/menu/home.blade.php index 1714446b61..af66198e65 100644 --- a/app/views/partials/menu/home.blade.php +++ b/app/views/partials/menu/home.blade.php @@ -23,7 +23,7 @@ $r = Route::current()->getName();