diff --git a/app/controllers/CategoryController.php b/app/controllers/CategoryController.php index 19ca21766f..cb9aa2c649 100644 --- a/app/controllers/CategoryController.php +++ b/app/controllers/CategoryController.php @@ -78,7 +78,14 @@ class CategoryController extends BaseController */ public function show(Category $category) { - return View::make('categories.show', compact('category')); + $hideCategory = true; + + /** @var \FireflyIII\Database\Category $repos */ + $repos = App::make('FireflyIII\Database\Category'); + + $journals = $repos->getTransactionJournals($category, 50); + + return View::make('categories.show', compact('category','journals','hideCategory')); } /** diff --git a/app/lib/FireflyIII/Database/Category.php b/app/lib/FireflyIII/Database/Category.php index 0e4085e439..faa11b7f65 100644 --- a/app/lib/FireflyIII/Database/Category.php +++ b/app/lib/FireflyIII/Database/Category.php @@ -170,6 +170,20 @@ class Category implements CUD, CommonDatabaseCalls, CategoryInterface throw new NotImplementedException; } + public function getTransactionJournals(\Category $category, $limit = 50) + { + $offset = intval(\Input::get('page')) > 0 ? intval(\Input::get('page')) * $limit : 0; + $set = $category->transactionJournals()->withRelevantData()->take($limit)->offset($offset)->orderBy('date', 'DESC')->get(['transaction_journals.*']); + $count = $category->transactionJournals()->count(); + $items = []; + foreach ($set as $entry) { + $items[] = $entry; + } + + return \Paginator::make($items, $count, $limit); + + } + /** * @param \Category $budget * @param Carbon $date diff --git a/app/views/categories/show.blade.php b/app/views/categories/show.blade.php index 594680d8ca..5cebffd6ed 100644 --- a/app/views/categories/show.blade.php +++ b/app/views/categories/show.blade.php @@ -17,7 +17,7 @@ Transactions