Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Cleanup and added todo's
James Cole7350b1da1b0f
diff --git a/app/controllers/BudgetController.php b/app/controllers/BudgetController.phpindex 134e758e05..62c2bb1372 100644--- a/app/controllers/BudgetController.php+++ b/app/controllers/BudgetController.php@@ -6,6 +6,10 @@ use FireflyIII\Shared\Preferences\PreferencesInterface as Pref;/*** Class BudgetController*+ * TODO move AJAX methods to their own BudgetAjaxControlle+ * TODO Find out what constitutes proper camelCase+ * TODO How is object coupling counted?+ ** @SuppressWarnings("CamelCase")* @SuppressWarnings("TooManyMethods")* @SuppressWarnings("CouplingBetweenObjects")diff --git a/app/controllers/CategoryController.php b/app/controllers/CategoryController.phpindex b0effea7da..a00e2d7421 100644--- a/app/controllers/CategoryController.php+++ b/app/controllers/CategoryController.php@@ -1,9 +1,13 @@<?phpuse FireflyIII\Database\Category as CategoryRepository;use FireflyIII\Exception\FireflyException;-use Illuminate\Support\MessageBag;/**+ *+ * TODO Find out what constitutes proper camelCase+ *+ * @SuppressWarnings("CamelCase")+ ** Class CategoryController*/class CategoryController extends BaseController@@ -94,44 +98,37 @@ class CategoryController extends BaseController*/public function store(){- $data = Input::all();- /** @var \FireflyIII\Database\Category $repos */- $repos = App::make('FireflyIII\Database\Category');-- switch ($data['post_submit_action']) {- default:- throw new FireflyException('Cannot handle post_submit_action "' . e($data['post_submit_action']) . '"');- break;- case 'create_another':- case 'store':- $messages = $repos->validate($data);- /** @var MessageBag $messages ['errors'] */- if ($messages['errors']->count() > 0) {- Session::flash('warnings', $messages['warnings']);- Session::flash('successes', $messages['successes']);- Session::flash('error', 'Could not save category: ' . $messages['errors']->first());-- return Redirect::route('categories.create')->withInput()->withErrors($messages['errors']);- }- // store!- $repos->store($data);- Session::flash('success', 'New category stored!');-- if ($data['post_submit_action'] == 'create_another') {- return Redirect::route('categories.create')->withInput();- } else {- return Redirect::route('categories.index');- }- break;- case 'validate_only':- $messageBags = $repos->validate($data);- Session::flash('warnings', $messageBags['warnings']);- Session::flash('successes', $messageBags['successes']);- Session::flash('errors', $messageBags['errors']);-- return Redirect::route('categories.create')->withInput();- break;+ $data = Input::except('_token');++ // always validate:+ $messages = $this->_repository->validate($data);++ // flash messages:+ Session::flash('warnings', $messages['warnings']);+ Session::flash('successes', $messages['successes']);+ Session::flash('errors', $messages['errors']);+ if ($messages['errors']->count() > 0) {+ Session::flash('error', 'Could not store category: ' . $messages['errors']->first());+ }++ // return to create screen:+ if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) {+ return Redirect::route('categories.create')->withInput();+ }++ // store:+ $this->_repository->store($data);+ Session::flash('success', 'Category "' . e($data['name']) . '" stored.');+ if ($data['post_submit_action'] == 'store') {+ return Redirect::route('categories.index');+ }++ // create another.+ if ($data['post_submit_action'] == 'create_another') {+ return Redirect::route('categories.create')->withInput();}++ return Redirect::route('categories.index');}/**@@ -142,44 +139,39 @@ class CategoryController extends BaseController*/public function update(Category $category){- /** @var \FireflyIII\Database\Category $repos */- $repos = App::make('FireflyIII\Database\Category');- $data = Input::except('_token');-- switch (Input::get('post_submit_action')) {- default:- throw new FireflyException('Cannot handle post_submit_action "' . e(Input::get('post_submit_action')) . '"');- break;- case 'return_to_edit':- case 'update':- $messages = $repos->validate($data);- /** @var MessageBag $messages ['errors'] */- if ($messages['errors']->count() > 0) {- Session::flash('warnings', $messages['warnings']);- Session::flash('successes', $messages['successes']);- Session::flash('error', 'Could not save category: ' . $messages['errors']->first());-- return Redirect::route('categories.edit', $category->id)->withInput()->withErrors($messages['errors']);- }- // store!- $repos->update($category, $data);- Session::flash('success', 'Category updated!');-- if ($data['post_submit_action'] == 'return_to_edit') {- return Redirect::route('categories.edit', $category->id);- } else {- return Redirect::route('categories.index');- }- case 'validate_only':- $messageBags = $repos->validate($data);- Session::flash('warnings', $messageBags['warnings']);- Session::flash('successes', $messageBags['successes']);- Session::flash('errors', $messageBags['errors']);-- return Redirect::route('categories.edit', $category->id)->withInput();- break;+ $data = Input::except('_token');++ // always validate:+ $messages = $this->_repository->validate($data);++ // flash messages:+ Session::flash('warnings', $messages['warnings']);+ Session::flash('successes', $messages['successes']);+ Session::flash('errors', $messages['errors']);+ if ($messages['errors']->count() > 0) {+ Session::flash('error', 'Could not update category: ' . $messages['errors']->first());+ }++ // return to update screen:+ if ($data['post_submit_action'] == 'validate_only' || $messages['errors']->count() > 0) {+ return Redirect::route('categories.edit', $category->id)->withInput();+ }++ // update+ $this->_repository->update($category, $data);+ Session::flash('success', 'Category "' . e($data['name']) . '" updated.');++ // go back to list+ if ($data['post_submit_action'] == 'update') {+ return Redirect::route('categories.index');+ }+ // go back to update screen.+ if ($data['post_submit_action'] == 'return_to_edit') {+ return Redirect::route('categories.edit', $category->id)->withInput(['post_submit_action' => 'return_to_edit']);}+ return Redirect::route('categories.index');+}