Fixed a bug that will properly attach both budgets AND categories

This commit is contained in:
Sander Dorigo 2014-10-08 21:39:27 +02:00
parent 0ef5825d98
commit d9b70f7ad8

View File

@ -93,6 +93,7 @@ class Transaction implements TransactionInterface
/* /*
* find budget using repository * find budget using repository
*/ */
if (isset($data['budget_id'])) { if (isset($data['budget_id'])) {
$budget = $this->_budgets->find($data['budget_id']); $budget = $this->_budgets->find($data['budget_id']);
} }
@ -172,8 +173,8 @@ class Transaction implements TransactionInterface
*/ */
$budgetids = !isset($budget) || (isset($budget) && is_null($budget)) ? [] : [$budget->id]; $budgetids = !isset($budget) || (isset($budget) && is_null($budget)) ? [] : [$budget->id];
$catids = is_null($category) ? [] : [$category->id]; $catids = is_null($category) ? [] : [$category->id];
$journal->budgets()->sync($budgetids); $components = array_merge($budgetids,$catids);
$journal->categories()->sync($catids); $journal->components()->sync($components);
$journal->save(); $journal->save();
if (isset($data['return_journal']) && $data['return_journal'] == true) { if (isset($data['return_journal']) && $data['return_journal'] == true) {
return $journal; return $journal;