Code cleanup [skip ci]

This commit is contained in:
James Cole 2015-01-01 23:12:12 +01:00
parent f27919f91b
commit e44de572f5
6 changed files with 24 additions and 24 deletions

View File

@ -70,7 +70,7 @@ class AccountController extends BaseController
public function create($what) public function create($what)
{ {
$subTitleIcon = $this->_subIconsByIdentifier[$what]; $subTitleIcon = $this->_subIconsByIdentifier[$what];
$subTitle = 'Create a new ' . $what . ' account'; $subTitle = 'Create a new ' . e($what) . ' account';
return View::make('accounts.create', compact('subTitleIcon', 'what', 'subTitle')); return View::make('accounts.create', compact('subTitleIcon', 'what', 'subTitle'));
} }
@ -82,7 +82,7 @@ class AccountController extends BaseController
*/ */
public function delete(Account $account) public function delete(Account $account)
{ {
$subTitle = 'Delete ' . strtolower($account->accountType->type) . ' "' . $account->name . '"'; $subTitle = 'Delete ' . strtolower(e($account->accountType->type)) . ' "' . e($account->name) . '"';
return View::make('accounts.delete', compact('account', 'subTitle')); return View::make('accounts.delete', compact('account', 'subTitle'));
} }
@ -101,7 +101,7 @@ class AccountController extends BaseController
$this->_repository->destroy($account); $this->_repository->destroy($account);
Session::flash('success', 'The ' . $typeName . ' account "' . e($name) . '" was deleted.'); Session::flash('success', 'The ' . e($typeName) . ' account "' . e($name) . '" was deleted.');
return Redirect::route('accounts.index', $typeName); return Redirect::route('accounts.index', $typeName);
} }
@ -116,7 +116,7 @@ class AccountController extends BaseController
$openingBalance = $this->_repository->openingBalanceTransaction($account); $openingBalance = $this->_repository->openingBalanceTransaction($account);
$subTitleIcon = $this->_subIconsByIdentifier[$account->accountType->type]; $subTitleIcon = $this->_subIconsByIdentifier[$account->accountType->type];
$subTitle = 'Edit ' . strtolower($account->accountType->type) . ' "' . $account->name . '"'; $subTitle = 'Edit ' . strtolower(e($account->accountType->type)) . ' "' . e($account->name) . '"';
// pre fill some useful values. // pre fill some useful values.
$preFilled = [ $preFilled = [
@ -157,7 +157,7 @@ class AccountController extends BaseController
$subTitleIcon = $this->_subIconsByIdentifier[$account->accountType->type]; $subTitleIcon = $this->_subIconsByIdentifier[$account->accountType->type];
$what = $this->_shortNamesByFullName[$account->accountType->type]; $what = $this->_shortNamesByFullName[$account->accountType->type];
$journals = $this->_repository->getTransactionJournals($account, 50, $range); $journals = $this->_repository->getTransactionJournals($account, 50, $range);
$subTitle = 'Details for ' . strtolower($account->accountType->type) . ' "' . $account->name . '"'; $subTitle = 'Details for ' . strtolower(e($account->accountType->type)) . ' "' . e($account->name) . '"';
return View::make('accounts.show', compact('account', 'what', 'range', 'subTitleIcon', 'journals', 'subTitle')); return View::make('accounts.show', compact('account', 'what', 'range', 'subTitleIcon', 'journals', 'subTitle'));
} }
@ -184,17 +184,17 @@ class AccountController extends BaseController
// return to create screen: // return to create screen:
if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) { if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) {
return Redirect::route('accounts.create', $data['what'])->withInput(); return Redirect::route('accounts.create', e($data['what']))->withInput();
} }
// store: // store:
$this->_repository->store($data); $this->_repository->store($data);
Session::flash('success', 'Account "' . e($data['name']) . '" stored.'); Session::flash('success', 'Account "' . e($data['name']) . '" stored.');
if ($data['post_submit_action'] == 'store') { if ($data['post_submit_action'] == 'store') {
return Redirect::route('accounts.index', $data['what']); return Redirect::route('accounts.index', e($data['what']));
} }
return Redirect::route('accounts.create', $data['what'])->withInput(); return Redirect::route('accounts.create', e($data['what']))->withInput();
} }
/** /**
@ -231,7 +231,7 @@ class AccountController extends BaseController
// go back to list // go back to list
if ($data['post_submit_action'] == 'update') { if ($data['post_submit_action'] == 'update') {
return Redirect::route('accounts.index', $data['what']); return Redirect::route('accounts.index', e($data['what']));
} }
// go back to update screen. // go back to update screen.

View File

@ -45,7 +45,7 @@ class BillController extends BaseController
public function delete(Bill $bill) public function delete(Bill $bill)
{ {
return View::make('bills.delete')->with('bill', $bill)->with( return View::make('bills.delete')->with('bill', $bill)->with(
'subTitle', 'Delete "' . $bill->name . '"' 'subTitle', 'Delete "' . e($bill->name) . '"'
); );
} }
@ -73,7 +73,7 @@ class BillController extends BaseController
$periods = \Config::get('firefly.periods_to_text'); $periods = \Config::get('firefly.periods_to_text');
return View::make('bills.edit')->with('periods', $periods)->with('bill', $bill)->with( return View::make('bills.edit')->with('periods', $periods)->with('bill', $bill)->with(
'subTitle', 'Edit "' . $bill->name . '"' 'subTitle', 'Edit "' . e($bill->name) . '"'
); );
} }
@ -119,7 +119,7 @@ class BillController extends BaseController
return View::make('bills.show', compact('journals', 'hideBill', 'bill'))->with( return View::make('bills.show', compact('journals', 'hideBill', 'bill'))->with(
'subTitle', $bill->name 'subTitle', e($bill->name)
); );
} }

View File

@ -41,7 +41,7 @@ class CategoryController extends BaseController
*/ */
public function delete(Category $category) public function delete(Category $category)
{ {
return View::make('categories.delete')->with('category', $category)->with('subTitle', 'Delete category "' . $category->name . '"'); return View::make('categories.delete')->with('category', $category)->with('subTitle', 'Delete category "' . e($category->name) . '"');
} }
/** /**
@ -65,7 +65,7 @@ class CategoryController extends BaseController
*/ */
public function edit(Category $category) public function edit(Category $category)
{ {
return View::make('categories.edit')->with('category', $category)->with('subTitle', 'Edit category "' . $category->name . '"'); return View::make('categories.edit')->with('category', $category)->with('subTitle', 'Edit category "' . e($category->name) . '"');
} }
/** /**

View File

@ -98,7 +98,7 @@ class TransactionController extends BaseController
$piggies[0] = '(no piggy bank)'; $piggies[0] = '(no piggy bank)';
$preFilled = Session::has('preFilled') ? Session::get('preFilled') : []; $preFilled = Session::has('preFilled') ? Session::get('preFilled') : [];
$respondTo = ['account_id', 'account_from_id']; $respondTo = ['account_id', 'account_from_id'];
$subTitle = 'Add a new ' . $what; $subTitle = 'Add a new ' . e($what);
foreach ($respondTo as $r) { foreach ($respondTo as $r) {
if (!is_null(Input::get($r))) { if (!is_null(Input::get($r))) {
@ -123,7 +123,7 @@ class TransactionController extends BaseController
public function delete(TransactionJournal $journal) public function delete(TransactionJournal $journal)
{ {
$type = strtolower($journal->transactionType->type); $type = strtolower($journal->transactionType->type);
$subTitle = 'Delete ' . $type . ' "' . $journal->description . '"'; $subTitle = 'Delete ' . e($type) . ' "' . e($journal->description) . '"';
return View::make('transactions.delete', compact('journal', 'subTitle')); return View::make('transactions.delete', compact('journal', 'subTitle'));
@ -197,7 +197,7 @@ class TransactionController extends BaseController
public function edit(TransactionJournal $journal) public function edit(TransactionJournal $journal)
{ {
$what = strtolower($journal->transactiontype->type); $what = strtolower($journal->transactiontype->type);
$subTitle = 'Edit ' . $what . ' "' . $journal->description . '"'; $subTitle = 'Edit ' . e($what) . ' "' . e($journal->description) . '"';
$budgets = FFForm::makeSelectList($this->_helper->getBudgets(), true); $budgets = FFForm::makeSelectList($this->_helper->getBudgets(), true);
$accounts = FFForm::makeSelectList($this->_helper->getAssetAccounts()); $accounts = FFForm::makeSelectList($this->_helper->getAssetAccounts());
$piggies = FFForm::makeSelectList($this->_helper->getPiggyBanks(), true); $piggies = FFForm::makeSelectList($this->_helper->getPiggyBanks(), true);
@ -346,7 +346,7 @@ class TransactionController extends BaseController
} }
return View::make('transactions.show', compact('journal', 'members'))->with( return View::make('transactions.show', compact('journal', 'members'))->with(
'subTitle', $journal->transactionType->type . ' "' . $journal->description . '"' 'subTitle', e($journal->transactionType->type) . ' "' . e($journal->description) . '"'
); );
} }

View File

@ -208,8 +208,8 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
return true; return true;
} else { } else {
var_dump($validation['errors']); \Log::error($validation['errors']->all());
exit; \App::abort(500);
} }
} }
@ -314,8 +314,8 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
$data = array_except($data, ['_token', 'what']); $data = array_except($data, ['_token', 'what']);
$account = new \Account($data); $account = new \Account($data);
if (!$account->isValid()) { if (!$account->isValid()) {
var_dump($account->getErrors()->all()); \Log::error($account->getErrors()->all());
exit; \App::abort(500);
} }
$account->save(); $account->save();
if (isset($data['openingbalance']) && floatval($data['openingbalance']) != 0) { if (isset($data['openingbalance']) && floatval($data['openingbalance']) != 0) {

View File

@ -285,8 +285,8 @@ class PiggyBank
$event->amount = $diff; $event->amount = $diff;
$event->date = new Carbon; $event->date = new Carbon;
if (!$event->isValid()) { if (!$event->isValid()) {
var_dump($event->getErrors()); \Log::error($event->getErrors());
exit(); \App::abort(500);
} }
$event->save(); $event->save();
} }