From d280767407faa7b455e5efb6c037854117f8e6d6 Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 15 Jul 2014 22:16:29 +0200 Subject: [PATCH] Code cleanup [skip-ci] --- app/controllers/AccountController.php | 12 ++- app/controllers/BaseController.php | 29 ++++--- app/controllers/ChartController.php | 35 +++++--- app/controllers/ComponentsController.php | 9 +- app/controllers/HomeController.php | 36 +++++--- app/controllers/JsonController.php | 29 ++++--- app/controllers/MigrationController.php | 32 +++++-- app/controllers/PreferencesController.php | 36 +++++--- app/controllers/ProfileController.php | 22 ++++- app/controllers/TransactionController.php | 87 ++++++++++++------- app/controllers/UserController.php | 3 + .../Firefly/Exception/FireflyException.php | 3 +- .../Firefly/Exception/MigrationException.php | 3 +- .../Helper/Email/EmailHelperInterface.php | 5 +- .../Helper/Migration/MigrationHelper.php | 4 +- .../PreferencesHelperInterface.php | 5 +- .../Helper/Toolkit/ToolkitInterface.php | 3 +- .../Account/EloquentAccountRepository.php | 4 +- .../Budget/BudgetRepositoryInterface.php | 1 + .../Component/EloquentComponentRepository.php | 4 +- .../Storage/StorageServiceProvider.php | 1 - .../EloquentTransactionRepository.php | 3 +- .../EloquentTransactionJournalRepository.php | 17 ++-- .../TransactionJournalRepositoryInterface.php | 2 + app/models/Account.php | 21 +++++ app/models/AccountType.php | 13 +++ app/models/Budget.php | 19 ++++ app/models/Category.php | 19 ++++ app/models/Component.php | 19 ++++ app/models/Preference.php | 17 ++++ app/models/Transaction.php | 23 +++++ app/models/TransactionCurrency.php | 13 +++ app/models/TransactionJournal.php | 30 +++++++ app/models/TransactionType.php | 13 +++ app/models/User.php | 25 ++++++ 35 files changed, 469 insertions(+), 128 deletions(-) diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index 78c7371aa5..2e85ab7fd3 100644 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -2,9 +2,15 @@ use Firefly\Storage\Account\AccountRepositoryInterface as ARI; +/** + * Class AccountController + */ class AccountController extends \BaseController { + /** + * @param ARI $accounts + */ public function __construct(ARI $accounts) { $this->accounts = $accounts; @@ -82,11 +88,11 @@ class AccountController extends \BaseController /** * Display the specified resource. * - * @param int $id + * @param int $accountId * * @return Response */ - public function show($id) + public function show($accountId) { } @@ -128,6 +134,4 @@ class AccountController extends \BaseController // } - - } diff --git a/app/controllers/BaseController.php b/app/controllers/BaseController.php index 2bee4644a0..bef3da1fe4 100644 --- a/app/controllers/BaseController.php +++ b/app/controllers/BaseController.php @@ -1,18 +1,21 @@ layout)) - { - $this->layout = View::make($this->layout); - } - } + /** + * Setup the layout used by the controller. + * + * @return void + */ + protected function setupLayout() + { + if (!is_null($this->layout)) { + $this->layout = View::make($this->layout); + } + } } diff --git a/app/controllers/ChartController.php b/app/controllers/ChartController.php index 369fb7c79c..181cf5ff25 100644 --- a/app/controllers/ChartController.php +++ b/app/controllers/ChartController.php @@ -4,36 +4,45 @@ use Firefly\Helper\Toolkit\Toolkit as tk; use Firefly\Storage\Account\AccountRepositoryInterface as ARI; use Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface as TJRI; +/** + * Class ChartController + */ class ChartController extends BaseController { - protected $accounts; - protected $journals; + protected $_accounts; + protected $_journals; + /** + * @param ARI $accounts + * @param TJRI $journals + */ public function __construct(ARI $accounts, TJRI $journals) { - $this->accounts = $accounts; - $this->journals = $journals; + $this->_accounts = $accounts; + $this->_journals = $journals; } /** - * Show home charts. + * @param null $accountId + * + * @return \Illuminate\Http\JsonResponse */ - public function homeAccount($id = null) + public function homeAccount($accountId = null) { list($start, $end) = tk::getDateRange(); $current = clone $start; $return = []; $account = null; - if(!is_null($id)) { - $account = $this->accounts->find($id); + if (!is_null($accountId)) { + $account = $this->_accounts->find($accountId); } if (is_null($account)) { - $accounts = $this->accounts->getActiveDefault(); + $accounts = $this->_accounts->getActiveDefault(); - foreach ($accounts as $index => $account) { + foreach ($accounts as $account) { $return[] = ['name' => $account->name, 'data' => []]; } while ($current <= $end) { @@ -69,7 +78,7 @@ class ChartController extends BaseController 'data' => [] ]; - $result = $this->journals->homeBudgetChart($start, $end); + $result = $this->_journals->homeBudgetChart($start, $end); foreach ($result as $name => $amount) { $data['data'][] = [$name, $amount]; @@ -85,7 +94,7 @@ class ChartController extends BaseController { list($start, $end) = tk::getDateRange(); - $result = $this->journals->homeCategoryChart($start, $end); + $result = $this->_journals->homeCategoryChart($start, $end); $data = [ 'type' => 'pie', 'name' => 'Amount: ', @@ -111,7 +120,7 @@ class ChartController extends BaseController 'data' => [] ]; - $result = $this->journals->homeBeneficiaryChart($start, $end); + $result = $this->_journals->homeBeneficiaryChart($start, $end); foreach ($result as $name => $amount) { $data['data'][] = [$name, $amount]; diff --git a/app/controllers/ComponentsController.php b/app/controllers/ComponentsController.php index edd100dcca..215473570f 100644 --- a/app/controllers/ComponentsController.php +++ b/app/controllers/ComponentsController.php @@ -1,7 +1,10 @@ accounts = $accounts; - $this->preferences = $preferences; - $this->tj = $tj; + $this->_accounts = $accounts; + $this->_preferences = $preferences; + $this->_journal = $journal; View::share('menu', 'home'); } + /** + * @return $this|\Illuminate\View\View + */ public function index() { // get list setting: - $pref = $this->preferences->get('frontpageAccounts', []); + $pref = $this->_preferences->get('frontpageAccounts', []); // get the accounts to display on the home screen: - $count = $this->accounts->count(); + $count = $this->_accounts->count(); if ($pref->data == []) { - $list = $this->accounts->getActiveDefault(); + $list = $this->_accounts->getActiveDefault(); } else { - $list = $this->accounts->getByIds($pref->data); + $list = $this->_accounts->getByIds($pref->data); } // get transactions for each account: foreach ($list as $account) { - $account->transactionList = $this->tj->getByAccount($account,10); + $account->transactionList = $this->_journal->getByAccount($account, 10); } diff --git a/app/controllers/JsonController.php b/app/controllers/JsonController.php index 1d29467199..30ae6608c1 100644 --- a/app/controllers/JsonController.php +++ b/app/controllers/JsonController.php @@ -5,19 +5,28 @@ use Firefly\Storage\Budget\BudgetRepositoryInterface as Bud; use Firefly\Storage\Category\CategoryRepositoryInterface as Cat; use Firefly\Storage\Component\ComponentRepositoryInterface as CRI; +/** + * Class JsonController + */ class JsonController extends BaseController { - protected $accounts; - protected $components; - protected $categories; - protected $budgets; + protected $_accounts; + protected $_components; + protected $_categories; + protected $_budgets; + /** + * @param ARI $accounts + * @param CRI $components + * @param Cat $categories + * @param Bud $budgets + */ public function __construct(ARI $accounts, CRI $components, Cat $categories, Bud $budgets) { - $this->components = $components; - $this->accounts = $accounts; - $this->categories = $categories; - $this->budgets = $budgets; + $this->_components = $components; + $this->_accounts = $accounts; + $this->_categories = $categories; + $this->_budgets = $budgets; } /** @@ -25,7 +34,7 @@ class JsonController extends BaseController */ public function beneficiaries() { - $list = $this->accounts->getBeneficiaries(); + $list = $this->_accounts->getBeneficiaries(); $return = []; foreach ($list as $entry) { $return[] = $entry->name; @@ -40,7 +49,7 @@ class JsonController extends BaseController */ public function categories() { - $list = $this->categories->get(); + $list = $this->_categories->get(); $return = []; foreach ($list as $entry) { $return[] = $entry->name; diff --git a/app/controllers/MigrationController.php b/app/controllers/MigrationController.php index 1d0f8a293b..dde53ab2e1 100644 --- a/app/controllers/MigrationController.php +++ b/app/controllers/MigrationController.php @@ -2,21 +2,33 @@ use Firefly\Helper\Migration\MigrationHelperInterface as MHI; +/** + * Class MigrationController + */ class MigrationController extends BaseController { - protected $migration; + protected $_migration; + /** + * @param MHI $migration + */ public function __construct(MHI $migration) { - $this->migration = $migration; + $this->_migration = $migration; View::share('menu', 'home'); } - public function dev() { + /** + * Dev method + */ + public function dev() + { $file = Config::get('dev.import'); - if(file_exists($file)) { + if (file_exists($file)) { $user = User::find(1); + + /** @noinspection PhpParamsInspection */ Auth::login($user); /** @var Firefly\Helper\Migration\MigrationHelperInterface $migration */ $migration = App::make('Firefly\Helper\Migration\MigrationHelperInterface'); @@ -27,11 +39,17 @@ class MigrationController extends BaseController } } + /** + * @return \Illuminate\View\View + */ public function index() { return View::make('migrate.index'); } + /** + * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\View\View + */ public function postIndex() { if (Input::hasFile('exportFile')) { @@ -40,12 +58,12 @@ class MigrationController extends BaseController $file = Input::file('exportFile'); $path = $file->getRealPath(); - $this->migration->loadFile($path); + $this->_migration->loadFile($path); - if (!$this->migration->validFile()) { + if (!$this->_migration->validFile()) { return View::make('error')->with('message', 'Invalid JSON content.'); } - $this->migration->migrate(); + $this->_migration->migrate(); return Redirect::route('index'); } else { return View::make('error')->with('message', 'No file selected'); diff --git a/app/controllers/PreferencesController.php b/app/controllers/PreferencesController.php index 7f2773c3d4..b8b62c9e07 100644 --- a/app/controllers/PreferencesController.php +++ b/app/controllers/PreferencesController.php @@ -3,43 +3,57 @@ use Firefly\Helper\Preferences\PreferencesHelperInterface as PHI; use Firefly\Storage\Account\AccountRepositoryInterface as ARI; +/** + * Class PreferencesController + */ class PreferencesController extends BaseController { - protected $accounts; - protected $preferences; + protected $_accounts; + protected $_preferences; + /** + * @param ARI $accounts + * @param PHI $preferences + */ public function __construct(ARI $accounts, PHI $preferences) { - $this->accounts = $accounts; - $this->preferences = $preferences; + $this->_accounts = $accounts; + $this->_preferences = $preferences; View::share('menu', 'home'); } + /** + * @return $this|\Illuminate\View\View + */ public function index() { - $accounts = $this->accounts->getDefault(); + $accounts = $this->_accounts->getDefault(); - $viewRange = $this->preferences->get('viewRange','1M'); + $viewRange = $this->_preferences->get('viewRange', '1M'); $viewRangeValue = $viewRange->data; // pref: - $frontpage = $this->preferences->get('frontpageAccounts', []); - return View::make('preferences.index')->with('accounts', $accounts)->with('frontpageAccounts', $frontpage)->with('viewRange',$viewRangeValue); + $frontpage = $this->_preferences->get('frontpageAccounts', []); + return View::make('preferences.index')->with('accounts', $accounts)->with('frontpageAccounts', $frontpage) + ->with('viewRange', $viewRangeValue); } + /** + * @return \Illuminate\Http\RedirectResponse + */ public function postIndex() { // frontpage accounts $frontpageAccounts = []; - foreach(Input::get('frontpageAccounts') as $id) { + foreach (Input::get('frontpageAccounts') as $id) { $frontpageAccounts[] = intval($id); } - $this->preferences->set('frontpageAccounts',$frontpageAccounts); + $this->_preferences->set('frontpageAccounts', $frontpageAccounts); // view range: - $this->preferences->set('viewRange',Input::get('viewRange')); + $this->_preferences->set('viewRange', Input::get('viewRange')); // forget session values: Session::forget('start'); Session::forget('end'); diff --git a/app/controllers/ProfileController.php b/app/controllers/ProfileController.php index a3fac53120..76f7784669 100644 --- a/app/controllers/ProfileController.php +++ b/app/controllers/ProfileController.php @@ -2,24 +2,41 @@ use Firefly\Storage\User\UserRepositoryInterface as URI; +/** + * Class ProfileController + */ class ProfileController extends BaseController { - public function __construct(URI $user) { + /** + * @param URI $user + */ + public function __construct(URI $user) + { $this->user = $user; View::share('menu', 'home'); } + /** + * @return \Illuminate\View\View + * + */ public function index() { return View::make('profile.index'); } + /** + * @return \Illuminate\View\View + */ public function changePassword() { return View::make('profile.change-password'); } + /** + * @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View + */ public function postChangePassword() { @@ -44,7 +61,8 @@ class ProfileController extends BaseController } // update the user with the new password. - $this->user->updatePassword(Auth::user(),Input::get('new1')); + /** @noinspection PhpParamsInspection */ + $this->user->updatePassword(Auth::user(), Input::get('new1')); Session::flash('success', 'Password changed!'); return Redirect::route('profile'); diff --git a/app/controllers/TransactionController.php b/app/controllers/TransactionController.php index 48b7c1f78a..2268295a6c 100644 --- a/app/controllers/TransactionController.php +++ b/app/controllers/TransactionController.php @@ -6,44 +6,59 @@ use Firefly\Storage\Budget\BudgetRepositoryInterface as Bud; use Firefly\Storage\Category\CategoryRepositoryInterface as Cat; use Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface as TJRI; +/** + * Class TransactionController + */ class TransactionController extends BaseController { - protected $accounts; - protected $budgets; - protected $categories; - protected $tj; + protected $_accounts; + protected $_budgets; + protected $_categories; + protected $_journal; - public function __construct(ARI $accounts, Bud $budgets, Cat $categories, TJRI $tj) + /** + * @param ARI $accounts + * @param Bud $budgets + * @param Cat $categories + * @param TJRI $journal + */ + public function __construct(ARI $accounts, Bud $budgets, Cat $categories, TJRI $journal) { - $this->accounts = $accounts; - $this->budgets = $budgets; - $this->categories = $categories; - $this->tj = $tj; + $this->_accounts = $accounts; + $this->_budgets = $budgets; + $this->_categories = $categories; + $this->_journal = $journal; View::share('menu', 'home'); } + /** + * @return $this|\Illuminate\View\View + */ public function createWithdrawal() { // get accounts with names and id's. - $accounts = $this->accounts->getActiveDefaultAsSelectList(); + $accounts = $this->_accounts->getActiveDefaultAsSelectList(); - $budgets = $this->budgets->getAsSelectList(); + $budgets = $this->_budgets->getAsSelectList(); $budgets[0] = '(no budget)'; return View::make('transactions.withdrawal')->with('accounts', $accounts)->with('budgets', $budgets); } + /** + * @return $this|\Illuminate\View\View + */ public function createDeposit() { // get accounts with names and id's. - $accounts = $this->accounts->getActiveDefaultAsSelectList(); + $accounts = $this->_accounts->getActiveDefaultAsSelectList(); - $budgets = $this->budgets->getAsSelectList(); + $budgets = $this->_budgets->getAsSelectList(); $budgets[0] = '(no budget)'; @@ -51,12 +66,15 @@ class TransactionController extends BaseController } + /** + * @return $this|\Illuminate\View\View + */ public function createTransfer() { // get accounts with names and id's. - $accounts = $this->accounts->getActiveDefaultAsSelectList(); + $accounts = $this->_accounts->getActiveDefaultAsSelectList(); - $budgets = $this->budgets->getAsSelectList(); + $budgets = $this->_budgets->getAsSelectList(); $budgets[0] = '(no budget)'; @@ -64,25 +82,28 @@ class TransactionController extends BaseController } + /** + * @return \Illuminate\Http\RedirectResponse + */ public function postCreateWithdrawal() { // create or find beneficiary: - $beneficiary = $this->accounts->createOrFindBeneficiary(Input::get('beneficiary')); + $beneficiary = $this->_accounts->createOrFindBeneficiary(Input::get('beneficiary')); // fall back to cash account if empty: if (is_null($beneficiary)) { - $beneficiary = $this->accounts->getCashAccount(); + $beneficiary = $this->_accounts->getCashAccount(); } // create or find category: - $category = $this->categories->createOrFind(Input::get('category')); + $category = $this->_categories->createOrFind(Input::get('category')); // find budget: - $budget = $this->budgets->find(intval(Input::get('budget_id'))); + $budget = $this->_budgets->find(intval(Input::get('budget_id'))); // find account: - $account = $this->accounts->find(intval(Input::get('account_id'))); + $account = $this->_accounts->find(intval(Input::get('account_id'))); // find amount & description: $description = trim(Input::get('description')); @@ -92,7 +113,7 @@ class TransactionController extends BaseController // create journal /** @var \TransactionJournal $journal */ try { - $journal = $this->tj->createSimpleJournal($account, $beneficiary, $description, $amount, $date); + $journal = $this->_journal->createSimpleJournal($account, $beneficiary, $description, $amount, $date); } catch (\Firefly\Exception\FireflyException $e) { return Redirect::route('transactions.withdrawal')->withInput(); } @@ -109,21 +130,24 @@ class TransactionController extends BaseController return Redirect::route('index'); } + /** + * @return \Illuminate\Http\RedirectResponse + */ public function postCreateDeposit() { // create or find beneficiary: - $beneficiary = $this->accounts->createOrFindBeneficiary(Input::get('beneficiary')); + $beneficiary = $this->_accounts->createOrFindBeneficiary(Input::get('beneficiary')); // fall back to cash account if empty: if (is_null($beneficiary)) { - $beneficiary = $this->accounts->getCashAccount(); + $beneficiary = $this->_accounts->getCashAccount(); } // create or find category: - $category = $this->categories->createOrFind(Input::get('category')); + $category = $this->_categories->createOrFind(Input::get('category')); // find account: - $account = $this->accounts->find(intval(Input::get('account_id'))); + $account = $this->_accounts->find(intval(Input::get('account_id'))); // find amount & description: $description = trim(Input::get('description')); @@ -133,7 +157,7 @@ class TransactionController extends BaseController // create journal /** @var \TransactionJournal $journal */ try { - $journal = $this->tj->createSimpleJournal($beneficiary, $account, $description, $amount, $date); + $journal = $this->_journal->createSimpleJournal($beneficiary, $account, $description, $amount, $date); } catch (\Firefly\Exception\FireflyException $e) { return Redirect::route('transactions.deposit')->withInput(); } @@ -146,16 +170,19 @@ class TransactionController extends BaseController return Redirect::route('index'); } + /** + * @return \Illuminate\Http\RedirectResponse + */ public function postCreateTransfer() { // create or find category: - $category = $this->categories->createOrFind(Input::get('category')); + $category = $this->_categories->createOrFind(Input::get('category')); // find account to: - $to = $this->accounts->find(intval(Input::get('account_to_id'))); + $toAccount = $this->_accounts->find(intval(Input::get('account_to_id'))); // find account from - $from = $this->accounts->find(intval(Input::get('account_from_id'))); + $from = $this->_accounts->find(intval(Input::get('account_from_id'))); // find amount & description: $description = trim(Input::get('description')); @@ -165,7 +192,7 @@ class TransactionController extends BaseController // create journal /** @var \TransactionJournal $journal */ try { - $journal = $this->tj->createSimpleJournal($from, $to, $description, $amount, $date); + $journal = $this->_journal->createSimpleJournal($from, $toAccount, $description, $amount, $date); } catch (\Firefly\Exception\FireflyException $e) { return Redirect::route('transactions.transfer')->withInput(); } diff --git a/app/controllers/UserController.php b/app/controllers/UserController.php index 0e7d7d813c..fa4e24ed36 100644 --- a/app/controllers/UserController.php +++ b/app/controllers/UserController.php @@ -3,6 +3,9 @@ use Firefly\Helper\Email\EmailHelperInterface as EHI; use Firefly\Storage\User\UserRepositoryInterface as URI; +/** + * Class UserController + */ class UserController extends BaseController { diff --git a/app/lib/Firefly/Exception/FireflyException.php b/app/lib/Firefly/Exception/FireflyException.php index c76f1affef..89f0ff939c 100644 --- a/app/lib/Firefly/Exception/FireflyException.php +++ b/app/lib/Firefly/Exception/FireflyException.php @@ -3,6 +3,7 @@ namespace Firefly\Exception; -class FireflyException extends \Exception { +class FireflyException extends \Exception +{ } \ No newline at end of file diff --git a/app/lib/Firefly/Exception/MigrationException.php b/app/lib/Firefly/Exception/MigrationException.php index 899ad4cfcd..2a31c70474 100644 --- a/app/lib/Firefly/Exception/MigrationException.php +++ b/app/lib/Firefly/Exception/MigrationException.php @@ -3,6 +3,7 @@ namespace Firefly\Helper; -class MigrationException extends \Exception { +class MigrationException extends \Exception +{ } \ No newline at end of file diff --git a/app/lib/Firefly/Helper/Email/EmailHelperInterface.php b/app/lib/Firefly/Helper/Email/EmailHelperInterface.php index 9f671f205c..43fe7ee52d 100644 --- a/app/lib/Firefly/Helper/Email/EmailHelperInterface.php +++ b/app/lib/Firefly/Helper/Email/EmailHelperInterface.php @@ -2,10 +2,13 @@ namespace Firefly\Helper\Email; -interface EmailHelperInterface { +interface EmailHelperInterface +{ public function sendVerificationMail(\User $user); + public function sendPasswordMail(\User $user); + public function sendResetVerification(\User $user); } \ No newline at end of file diff --git a/app/lib/Firefly/Helper/Migration/MigrationHelper.php b/app/lib/Firefly/Helper/Migration/MigrationHelper.php index 0e373da2fe..c3a9e95b59 100644 --- a/app/lib/Firefly/Helper/Migration/MigrationHelper.php +++ b/app/lib/Firefly/Helper/Migration/MigrationHelper.php @@ -192,11 +192,11 @@ class MigrationHelper implements MigrationHelperInterface $journal = $journals->createSimpleJournal($fromAccount, $toAccount, $entry->description, $amount, $date); // save budgets and categories, on the journal - if(isset($budgets[$entry->id])) { + if (isset($budgets[$entry->id])) { $budget = $budgets[$entry->id]; $journal->budgets()->save($budget); } - if(isset($categories[$entry->id])) { + if (isset($categories[$entry->id])) { $category = $categories[$entry->id]; $journal->categories()->save($category); } diff --git a/app/lib/Firefly/Helper/Preferences/PreferencesHelperInterface.php b/app/lib/Firefly/Helper/Preferences/PreferencesHelperInterface.php index 2c3cd6c6aa..1e80350432 100644 --- a/app/lib/Firefly/Helper/Preferences/PreferencesHelperInterface.php +++ b/app/lib/Firefly/Helper/Preferences/PreferencesHelperInterface.php @@ -3,7 +3,8 @@ namespace Firefly\Helper\Preferences; interface PreferencesHelperInterface { - public function set($name,$value); - public function get($name,$default = null); + public function set($name, $value); + + public function get($name, $default = null); } \ No newline at end of file diff --git a/app/lib/Firefly/Helper/Toolkit/ToolkitInterface.php b/app/lib/Firefly/Helper/Toolkit/ToolkitInterface.php index b158e0c47e..1e36e18a64 100644 --- a/app/lib/Firefly/Helper/Toolkit/ToolkitInterface.php +++ b/app/lib/Firefly/Helper/Toolkit/ToolkitInterface.php @@ -3,7 +3,8 @@ namespace Firefly\Helper\Toolkit; -interface ToolkitInterface { +interface ToolkitInterface +{ public static function getDateRange(); } \ No newline at end of file diff --git a/app/lib/Firefly/Storage/Account/EloquentAccountRepository.php b/app/lib/Firefly/Storage/Account/EloquentAccountRepository.php index 3ccdfadf47..2de96e0792 100644 --- a/app/lib/Firefly/Storage/Account/EloquentAccountRepository.php +++ b/app/lib/Firefly/Storage/Account/EloquentAccountRepository.php @@ -156,8 +156,8 @@ class EloquentAccountRepository implements AccountRepositoryInterface public function getCashAccount() { - $type = \AccountType::where('description','Cash account')->first(); - $cash = \Auth::user()->accounts()->where('account_type_id',$type->id)->first(); + $type = \AccountType::where('description', 'Cash account')->first(); + $cash = \Auth::user()->accounts()->where('account_type_id', $type->id)->first(); return $cash; } diff --git a/app/lib/Firefly/Storage/Budget/BudgetRepositoryInterface.php b/app/lib/Firefly/Storage/Budget/BudgetRepositoryInterface.php index 89577d8eed..e0896cf387 100644 --- a/app/lib/Firefly/Storage/Budget/BudgetRepositoryInterface.php +++ b/app/lib/Firefly/Storage/Budget/BudgetRepositoryInterface.php @@ -6,6 +6,7 @@ namespace Firefly\Storage\Budget; interface BudgetRepositoryInterface { public function getAsSelectList(); + public function find($id); } \ No newline at end of file diff --git a/app/lib/Firefly/Storage/Component/EloquentComponentRepository.php b/app/lib/Firefly/Storage/Component/EloquentComponentRepository.php index d59a098e74..631e234260 100644 --- a/app/lib/Firefly/Storage/Component/EloquentComponentRepository.php +++ b/app/lib/Firefly/Storage/Component/EloquentComponentRepository.php @@ -17,12 +17,12 @@ class EloquentComponentRepository implements ComponentRepositoryInterface } - public function get() { + public function get() + { die('no impl'); } - public function store($data) { if (!isset($data['class'])) { diff --git a/app/lib/Firefly/Storage/StorageServiceProvider.php b/app/lib/Firefly/Storage/StorageServiceProvider.php index e286c16e56..ddd66b5861 100644 --- a/app/lib/Firefly/Storage/StorageServiceProvider.php +++ b/app/lib/Firefly/Storage/StorageServiceProvider.php @@ -20,7 +20,6 @@ class StorageServiceProvider extends ServiceProvider ); - $this->app->bind( 'Firefly\Storage\Account\AccountRepositoryInterface', 'Firefly\Storage\Account\EloquentAccountRepository' diff --git a/app/lib/Firefly/Storage/Transaction/EloquentTransactionRepository.php b/app/lib/Firefly/Storage/Transaction/EloquentTransactionRepository.php index 7b0ecf6796..32b485a04f 100644 --- a/app/lib/Firefly/Storage/Transaction/EloquentTransactionRepository.php +++ b/app/lib/Firefly/Storage/Transaction/EloquentTransactionRepository.php @@ -3,6 +3,7 @@ namespace Firefly\Storage\Transaction; -class EloquentTransactionRepository implements TransactionRepositoryInterface { +class EloquentTransactionRepository implements TransactionRepositoryInterface +{ } \ No newline at end of file diff --git a/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.php b/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.php index 1f9fc79d38..c3380ee3b3 100644 --- a/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.php +++ b/app/lib/Firefly/Storage/TransactionJournal/EloquentTransactionJournalRepository.php @@ -38,15 +38,15 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito $amountFrom = $amount * -1; $amountTo = $amount; - if(round(floatval($amount),2) == 0.00) { + if (round(floatval($amount), 2) == 0.00) { \Log::error('Transaction will never save: amount = 0'); - \Session::flash('error','The amount should not be empty or zero.'); + \Session::flash('error', 'The amount should not be empty or zero.'); throw new \Firefly\Exception\FireflyException('Could not figure out transaction type.'); } // same account: - if($from->id == $to->id) { + if ($from->id == $to->id) { \Log::error('Accounts cannot be equal'); - \Session::flash('error','Select two different accounts.'); + \Session::flash('error', 'Select two different accounts.'); throw new \Firefly\Exception\FireflyException('Select two different accounts.'); } @@ -108,7 +108,7 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito if (!$journal->save()) { \Log::error('Cannot create valid journal.'); \Log::error('Errors: ' . print_r($journal->errors()->all(), true)); - \Session::flash('error','Could not create journal: ' . $journal->errors()->first()); + \Session::flash('error', 'Could not create journal: ' . $journal->errors()->first()); throw new \Firefly\Exception\FireflyException('Cannot create valid journal.'); } $journal->save(); @@ -173,7 +173,7 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito }] ) ->after($start)->before($end) - ->where('completed',1) + ->where('completed', 1) ->whereIn('transaction_type_id', $types) ->get(['transaction_journals.*']); unset($types); @@ -182,8 +182,9 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito foreach ($journals as $journal) { // has to be one: - if(!isset($journal->transactions[0])) { - throw new FireflyException('Journal #'.$journal->id.' has ' . count($journal->transactions).' transactions!'); + if (!isset($journal->transactions[0])) { + throw new FireflyException('Journal #' . $journal->id . ' has ' . count($journal->transactions) + . ' transactions!'); } $transaction = $journal->transactions[0]; $amount = floatval($transaction->amount); diff --git a/app/lib/Firefly/Storage/TransactionJournal/TransactionJournalRepositoryInterface.php b/app/lib/Firefly/Storage/TransactionJournal/TransactionJournalRepositoryInterface.php index d7cc4aa5d5..a19bca137e 100644 --- a/app/lib/Firefly/Storage/TransactionJournal/TransactionJournalRepositoryInterface.php +++ b/app/lib/Firefly/Storage/TransactionJournal/TransactionJournalRepositoryInterface.php @@ -12,7 +12,9 @@ interface TransactionJournalRepositoryInterface public function getByAccount(\Account $account, $count = 25); public function homeBudgetChart(\Carbon\Carbon $start, \Carbon\Carbon $end); + public function homeCategoryChart(\Carbon\Carbon $start, \Carbon\Carbon $end); + public function homeBeneficiaryChart(\Carbon\Carbon $start, \Carbon\Carbon $end); public function homeComponentChart(\Carbon\Carbon $start, \Carbon\Carbon $end, $chartType); diff --git a/app/models/Account.php b/app/models/Account.php index 319eb1b215..cb4e23754d 100644 --- a/app/models/Account.php +++ b/app/models/Account.php @@ -1,6 +1,27 @@ hasMany('TransactionJournal'); diff --git a/app/models/User.php b/app/models/User.php index a9856114d6..fa90743c6d 100644 --- a/app/models/User.php +++ b/app/models/User.php @@ -7,6 +7,31 @@ use Illuminate\Auth\UserTrait; use LaravelBook\Ardent\Ardent; +/** + * User + * + * @property integer $id + * @property \Carbon\Carbon $created_at + * @property \Carbon\Carbon $updated_at + * @property string $email + * @property string $password + * @property string $reset + * @property string $remember_token + * @property boolean $migrated + * @property-read \Illuminate\Database\Eloquent\Collection|\Account[] $accounts + * @property-read \Illuminate\Database\Eloquent\Collection|\Preference[] $preferences + * @property-read \Illuminate\Database\Eloquent\Collection|\Component[] $components + * @property-read \Illuminate\Database\Eloquent\Collection|\Budget[] $budgets + * @property-read \Illuminate\Database\Eloquent\Collection|\Category[] $categories + * @method static \Illuminate\Database\Query\Builder|\User whereId($value) + * @method static \Illuminate\Database\Query\Builder|\User whereCreatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\User whereUpdatedAt($value) + * @method static \Illuminate\Database\Query\Builder|\User whereEmail($value) + * @method static \Illuminate\Database\Query\Builder|\User wherePassword($value) + * @method static \Illuminate\Database\Query\Builder|\User whereReset($value) + * @method static \Illuminate\Database\Query\Builder|\User whereRememberToken($value) + * @method static \Illuminate\Database\Query\Builder|\User whereMigrated($value) + */ class User extends Ardent implements UserInterface, RemindableInterface {