Some cleanup and a small bug fix.

This commit is contained in:
James Cole 2014-12-12 07:42:38 +01:00
parent cb2863eaf3
commit 136adbe723
3 changed files with 23 additions and 22 deletions

View File

@ -145,11 +145,12 @@ class BudgetController extends BaseController
App::abort(500); App::abort(500);
} }
$hideBudget = true; // used in transaction list.
$journals = $this->_repository->getJournals($budget, $repetition); $journals = $this->_repository->getJournals($budget, $repetition);
$limits = $repetition ? $budget->limits()->orderBy('startdate', 'DESC')->get() : [$repetition->limit]; $limits = $repetition ? $budget->limits()->orderBy('startdate', 'DESC')->get() : [$repetition->limit];
$subTitle = $repetition ? e($budget->name) . ' in ' . $repetition->startdate->format('F Y') : e($budget->name); $subTitle = $repetition ? e($budget->name) . ' in ' . $repetition->startdate->format('F Y') : e($budget->name);
return View::make('budgets.show', compact('limits', 'budget', 'repetition', 'journals', 'subTitle')); return View::make('budgets.show', compact('limits', 'budget', 'repetition', 'journals', 'subTitle', 'hideBudget'));
} }
/** /**
@ -239,6 +240,7 @@ class BudgetController extends BaseController
public function updateIncome() public function updateIncome()
{ {
$budgetAmount = $this->_preferences->get('budgetIncomeTotal' . Session::get('start')->format('FY'), 1000); $budgetAmount = $this->_preferences->get('budgetIncomeTotal' . Session::get('start')->format('FY'), 1000);
return View::make('budgets.income')->with('amount', $budgetAmount); return View::make('budgets.income')->with('amount', $budgetAmount);
} }
} }

View File

@ -1,4 +1,5 @@
<?php <?php
use FireflyIII\Database\Category as CategoryRepository;
use FireflyIII\Exception\FireflyException; use FireflyIII\Exception\FireflyException;
use Illuminate\Support\MessageBag; use Illuminate\Support\MessageBag;
@ -7,13 +8,19 @@ use Illuminate\Support\MessageBag;
*/ */
class CategoryController extends BaseController class CategoryController extends BaseController
{ {
/** @var CategoryRepository */
protected $_repository;
/** /**
* * @param CategoryRepository $repository
*/ */
public function __construct() public function __construct(CategoryRepository $repository)
{ {
View::share('title', 'Categories'); View::share('title', 'Categories');
View::share('mainTitleIcon', 'fa-bar-chart'); View::share('mainTitleIcon', 'fa-bar-chart');
$this->_repository = $repository;
} }
/** /**
@ -41,11 +48,9 @@ class CategoryController extends BaseController
*/ */
public function destroy(Category $category) public function destroy(Category $category)
{ {
/** @var \FireflyIII\Database\Category $repos */ Session::flash('success', 'Category "' . e($category->name) . '" was deleted.');
$repos = App::make('FireflyIII\Database\Category'); $this->_repository->destroy($category);
$repos->destroy($category);
Session::flash('success', 'The category was deleted.');
return Redirect::route('categories.index'); return Redirect::route('categories.index');
} }
@ -65,9 +70,7 @@ class CategoryController extends BaseController
*/ */
public function index() public function index()
{ {
/** @var \FireflyIII\Database\Category $repos */ $categories = $this->_repository->get();
$repos = App::make('FireflyIII\Database\Category');
$categories = $repos->get();
return View::make('categories.index', compact('categories')); return View::make('categories.index', compact('categories'));
} }
@ -79,12 +82,8 @@ class CategoryController extends BaseController
*/ */
public function show(Category $category) public function show(Category $category)
{ {
$hideCategory = true; $hideCategory = true; // used in list.
$journals = $this->_repository->getTransactionJournals($category, 50);
/** @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')); return View::make('categories.show', compact('category', 'journals', 'hideCategory'));
} }

View File

@ -185,8 +185,8 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
if (!is_null($repetition)) { if (!is_null($repetition)) {
$setQuery->before($repetition->startdate)->after($repetition->enddate); $setQuery->after($repetition->startdate)->before($repetition->enddate);
$countQuery->before($repetition->startdate)->after($repetition->enddate); $countQuery->after($repetition->startdate)->before($repetition->enddate);
} }