[Fixes #21] Change the majority of View::share to View::make()->with()

This commit is contained in:
Stewart Malik 2014-11-10 02:27:19 +10:30
parent 27e3ec693a
commit 1ff135d172
4 changed files with 57 additions and 47 deletions

View File

@ -31,19 +31,22 @@ class AccountController extends BaseController
throw new FireflyException('Cannot handle account type "' . e($what) . '".'); throw new FireflyException('Cannot handle account type "' . e($what) . '".');
break; break;
case 'asset': case 'asset':
View::share('subTitleIcon', 'fa-money'); $subTitleIcon = 'fa-money';
View::share('subTitle', 'Asset accounts'); $subTitle = 'Asset accounts';
break; break;
case 'expense': case 'expense':
View::share('subTitleIcon', 'fa-shopping-cart'); $subTitleIcon = 'fa-shopping-cart';
View::share('subTitle', 'Expense accounts'); $subTitle = 'Expense accounts';
break; break;
case 'revenue': case 'revenue':
View::share('subTitleIcon', 'fa-download'); $subTitleIcon = 'fa-download';
View::share('subTitle', 'Revenue accounts'); $subTitle = 'Revenue accounts';
break; break;
} }
return View::make('accounts.index')->with('what', $what); return View::make('accounts.index')
->with('what', $what)
->with(compact('subTitleIcon'))
->with(compact('subTitle'));
} }
@ -118,17 +121,20 @@ class AccountController extends BaseController
{ {
switch ($what) { switch ($what) {
case 'asset': case 'asset':
View::share('subTitleIcon', 'fa-money'); $subTitleIcon = 'fa-money';
break; break;
case 'expense': case 'expense':
View::share('subTitleIcon', 'fa-shopping-cart'); $subTitleIcon = 'fa-shopping-cart';
break; break;
case 'revenue': case 'revenue':
View::share('subTitleIcon', 'fa-download'); $subTitleIcon = 'fa-download';
break; break;
} }
return View::make('accounts.create')->with('subTitle', 'Create a new ' . $what . ' account')->with('what', $what); return View::make('accounts.create')
->with('subTitle', 'Create a new ' . $what . ' account')
->with('what', $what)
->with(compact('subTitleIcon'));
} }
/** /**
@ -229,14 +235,14 @@ class AccountController extends BaseController
switch ($account->accountType->type) { switch ($account->accountType->type) {
case 'Asset account': case 'Asset account':
case 'Default account': case 'Default account':
View::share('subTitleIcon', 'fa-money'); $subTitleIcon = 'fa-money';
break; break;
case 'Expense account': case 'Expense account':
case 'Beneficiary account': case 'Beneficiary account':
View::share('subTitleIcon', 'fa-shopping-cart'); $subTitleIcon = 'fa-shopping-cart';
break; break;
case 'Revenue account': case 'Revenue account':
View::share('subTitleIcon', 'fa-download'); $subTitleIcon = 'fa-download';
break; break;
} }
@ -251,9 +257,11 @@ class AccountController extends BaseController
Session::flash('prefilled', $prefilled); Session::flash('prefilled', $prefilled);
} }
return View::make('accounts.edit')
return View::make('accounts.edit')->with('account', $account)->with('openingBalance', $openingBalance)->with( ->with('account', $account)
'subTitle', 'Edit ' . strtolower( ->with('openingBalance', $openingBalance)
->with(compact('subTitleIcon'))
->with('subTitle', 'Edit ' . strtolower(
$account->accountType->type $account->accountType->type
) . ' "' . $account->name . '"' ) . ' "' . $account->name . '"'
); );
@ -269,22 +277,23 @@ class AccountController extends BaseController
switch ($account->accountType->type) { switch ($account->accountType->type) {
case 'Asset account': case 'Asset account':
case 'Default account': case 'Default account':
View::share('subTitleIcon', 'fa-money'); $subTitleIcon = 'fa-money';
break; break;
case 'Expense account': case 'Expense account':
case 'Beneficiary account': case 'Beneficiary account':
View::share('subTitleIcon', 'fa-shopping-cart'); $subTitleIcon = 'fa-shopping-cart';
break; break;
case 'Revenue account': case 'Revenue account':
View::share('subTitleIcon', 'fa-download'); $subTitleIcon = 'fa-download';
break; break;
} }
//$data = $this->_accounts->show($account, 40); //$data = $this->_accounts->show($account, 40);
return View::make('accounts.show') return View::make('accounts.show')
->with('account', $account) ->with('account', $account)
->with('subTitle', 'Details for ' . strtolower($account->accountType->type) . ' "' . $account->name . '"'); ->with('subTitle', 'Details for ' . strtolower($account->accountType->type) . ' "' . $account->name . '"')
->with(compact('subTitleIcon'));
} }
/** /**

View File

@ -46,11 +46,11 @@ class PiggybankController extends BaseController
*/ */
public function delete(Piggybank $piggybank) public function delete(Piggybank $piggybank)
{ {
View::share('subTitle', 'Delete "' . $piggybank->name . '"'); return View::make('piggybanks.delete')
View::share('title', 'Piggy banks'); ->with('piggybank', $piggybank)
View::share('mainTitleIcon', 'fa-sort-amount-asc'); ->with('subTitle', 'Delete "' . $piggybank->name . '"')
->with('title', 'Piggy banks')
return View::make('piggybanks.delete')->with('piggybank', $piggybank); ->with('mainTitleIcon', 'fa-sort-amount-asc');
} }
/** /**

View File

@ -22,10 +22,10 @@ class ProfileController extends BaseController
*/ */
public function index() public function index()
{ {
View::share('title', 'Profile'); return View::make('profile.index')
View::share('subTitle', Auth::user()->email); ->with('title', 'Profile')
View::share('mainTitleIcon', 'fa-user'); ->with('subTitle', Auth::user()->email)
return View::make('profile.index'); ->with('mainTitleIcon', 'fa-user');
} }
/** /**
@ -33,10 +33,10 @@ class ProfileController extends BaseController
*/ */
public function changePassword() public function changePassword()
{ {
View::share('title', Auth::user()->email); return View::make('profile.change-password')
View::share('subTitle', 'Change your password'); ->with('title', Auth::user()->email)
View::share('mainTitleIcon', 'fa-user'); ->with('subTitle', 'Change your password')
return View::make('profile.change-password'); ->with('mainTitleIcon', 'fa-user');
} }
/** /**

View File

@ -32,10 +32,11 @@ class RecurringController extends BaseController
*/ */
public function create() public function create()
{ {
View::share('subTitle', 'Create new');
$periods = \Config::get('firefly.periods_to_text'); $periods = \Config::get('firefly.periods_to_text');
return View::make('recurring.create')->with('periods', $periods); return View::make('recurring.create')
->with('periods', $periods)
->with('subTitle', 'Create new');
} }
/** /**
@ -45,8 +46,9 @@ class RecurringController extends BaseController
*/ */
public function delete(RecurringTransaction $recurringTransaction) public function delete(RecurringTransaction $recurringTransaction)
{ {
View::share('subTitle', 'Delete "' . $recurringTransaction->name . '"'); return View::make('recurring.delete')
return View::make('recurring.delete')->with('recurringTransaction', $recurringTransaction); ->with('recurringTransaction', $recurringTransaction)
->with('subTitle', 'Delete "' . $recurringTransaction->name . '"');
} }
/** /**
@ -77,11 +79,10 @@ class RecurringController extends BaseController
{ {
$periods = \Config::get('firefly.periods_to_text'); $periods = \Config::get('firefly.periods_to_text');
View::share('subTitle', 'Edit "' . $recurringTransaction->name . '"'); return View::make('recurring.edit')
->with('periods', $periods)
return View::make('recurring.edit')->with('periods', $periods)->with( ->with('recurringTransaction', $recurringTransaction)
'recurringTransaction', $recurringTransaction ->with('subTitle', 'Edit "' . $recurringTransaction->name . '"');
);
} }
/** /**
@ -97,9 +98,9 @@ class RecurringController extends BaseController
*/ */
public function show(RecurringTransaction $recurringTransaction) public function show(RecurringTransaction $recurringTransaction)
{ {
View::share('subTitle', $recurringTransaction->name); return View::make('recurring.show')
return View::make('recurring.show')->with('recurring', $recurringTransaction); ->with('recurring', $recurringTransaction)
->with('subTitle', $recurringTransaction->name);
} }
/** /**