Skip to content

Commit

Permalink
Merge pull request #31 from sonikarc/develop
Browse files Browse the repository at this point in the history
[Fixes #21] Change the majority of View::share to View::make()->with()
  • Loading branch information
JC5 committed Nov 10, 2014
2 parents def791c + 1a8ba83 commit 99c72c8
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 47 deletions.
53 changes: 31 additions & 22 deletions app/controllers/AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,22 @@ public function index($what = 'default')
throw new FireflyException('Cannot handle account type "' . e($what) . '".');
break;
case 'asset':
View::share('subTitleIcon', 'fa-money');
View::share('subTitle', 'Asset accounts');
$subTitleIcon = 'fa-money';
$subTitle = 'Asset accounts';
break;
case 'expense':
View::share('subTitleIcon', 'fa-shopping-cart');
View::share('subTitle', 'Expense accounts');
$subTitleIcon = 'fa-shopping-cart';
$subTitle = 'Expense accounts';
break;
case 'revenue':
View::share('subTitleIcon', 'fa-download');
View::share('subTitle', 'Revenue accounts');
$subTitleIcon = 'fa-download';
$subTitle = 'Revenue accounts';
break;
}
return View::make('accounts.index')->with('what', $what);
return View::make('accounts.index')
->with('what', $what)
->with(compact('subTitleIcon'))
->with(compact('subTitle'));
}


Expand Down Expand Up @@ -118,17 +121,20 @@ public function create($what)
{
switch ($what) {
case 'asset':
View::share('subTitleIcon', 'fa-money');
$subTitleIcon = 'fa-money';
break;
case 'expense':
View::share('subTitleIcon', 'fa-shopping-cart');
$subTitleIcon = 'fa-shopping-cart';
break;
case 'revenue':
View::share('subTitleIcon', 'fa-download');
$subTitleIcon = 'fa-download';
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'));
}

/**
Expand Down Expand Up @@ -229,14 +235,14 @@ public function edit(Account $account)
switch ($account->accountType->type) {
case 'Asset account':
case 'Default account':
View::share('subTitleIcon', 'fa-money');
$subTitleIcon = 'fa-money';
break;
case 'Expense account':
case 'Beneficiary account':
View::share('subTitleIcon', 'fa-shopping-cart');
$subTitleIcon = 'fa-shopping-cart';
break;
case 'Revenue account':
View::share('subTitleIcon', 'fa-download');
$subTitleIcon = 'fa-download';
break;
}

Expand All @@ -251,9 +257,11 @@ public function edit(Account $account)
Session::flash('prefilled', $prefilled);
}


return View::make('accounts.edit')->with('account', $account)->with('openingBalance', $openingBalance)->with(
'subTitle', 'Edit ' . strtolower(
return View::make('accounts.edit')
->with('account', $account)
->with('openingBalance', $openingBalance)
->with(compact('subTitleIcon'))
->with('subTitle', 'Edit ' . strtolower(
$account->accountType->type
) . ' "' . $account->name . '"'
);
Expand All @@ -269,22 +277,23 @@ public function show(Account $account)
switch ($account->accountType->type) {
case 'Asset account':
case 'Default account':
View::share('subTitleIcon', 'fa-money');
$subTitleIcon = 'fa-money';
break;
case 'Expense account':
case 'Beneficiary account':
View::share('subTitleIcon', 'fa-shopping-cart');
$subTitleIcon = 'fa-shopping-cart';
break;
case 'Revenue account':
View::share('subTitleIcon', 'fa-download');
$subTitleIcon = 'fa-download';
break;
}


//$data = $this->_accounts->show($account, 40);
return View::make('accounts.show')
->with('account', $account)
->with('subTitle', 'Details for ' . strtolower($account->accountType->type) . ' "' . $account->name . '"');
->with('account', $account)
->with('subTitle', 'Details for ' . strtolower($account->accountType->type) . ' "' . $account->name . '"')
->with(compact('subTitleIcon'));
}

/**
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/PiggybankController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ public function create()
*/
public function delete(Piggybank $piggybank)
{
View::share('subTitle', 'Delete "' . $piggybank->name . '"');
View::share('title', 'Piggy banks');
View::share('mainTitleIcon', 'fa-sort-amount-asc');

return View::make('piggybanks.delete')->with('piggybank', $piggybank);
return View::make('piggybanks.delete')
->with('piggybank', $piggybank)
->with('subTitle', 'Delete "' . $piggybank->name . '"')
->with('title', 'Piggy banks')
->with('mainTitleIcon', 'fa-sort-amount-asc');
}

/**
Expand Down
16 changes: 8 additions & 8 deletions app/controllers/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ public function __construct(URI $user)
*/
public function index()
{
View::share('title', 'Profile');
View::share('subTitle', Auth::user()->email);
View::share('mainTitleIcon', 'fa-user');
return View::make('profile.index');
return View::make('profile.index')
->with('title', 'Profile')
->with('subTitle', Auth::user()->email)
->with('mainTitleIcon', 'fa-user');
}

/**
* @return \Illuminate\View\View
*/
public function changePassword()
{
View::share('title', Auth::user()->email);
View::share('subTitle', 'Change your password');
View::share('mainTitleIcon', 'fa-user');
return View::make('profile.change-password');
return View::make('profile.change-password')
->with('title', Auth::user()->email)
->with('subTitle', 'Change your password')
->with('mainTitleIcon', 'fa-user');
}

/**
Expand Down
25 changes: 13 additions & 12 deletions app/controllers/RecurringController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ public function __construct(RTR $repository, RI $helper)
*/
public function create()
{
View::share('subTitle', 'Create new');
$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');
}

/**
Expand All @@ -45,8 +46,9 @@ public function create()
*/
public function delete(RecurringTransaction $recurringTransaction)
{
View::share('subTitle', 'Delete "' . $recurringTransaction->name . '"');
return View::make('recurring.delete')->with('recurringTransaction', $recurringTransaction);
return View::make('recurring.delete')
->with('recurringTransaction', $recurringTransaction)
->with('subTitle', 'Delete "' . $recurringTransaction->name . '"');
}

/**
Expand Down Expand Up @@ -77,11 +79,10 @@ public function edit(RecurringTransaction $recurringTransaction)
{
$periods = \Config::get('firefly.periods_to_text');

View::share('subTitle', 'Edit "' . $recurringTransaction->name . '"');

return View::make('recurring.edit')->with('periods', $periods)->with(
'recurringTransaction', $recurringTransaction
);
return View::make('recurring.edit')
->with('periods', $periods)
->with('recurringTransaction', $recurringTransaction)
->with('subTitle', 'Edit "' . $recurringTransaction->name . '"');
}

/**
Expand All @@ -97,9 +98,9 @@ public function index()
*/
public function show(RecurringTransaction $recurringTransaction)
{
View::share('subTitle', $recurringTransaction->name);
return View::make('recurring.show')->with('recurring', $recurringTransaction);

return View::make('recurring.show')
->with('recurring', $recurringTransaction)
->with('subTitle', $recurringTransaction->name);
}

/**
Expand Down

0 comments on commit 99c72c8

Please sign in to comment.