Skip to content

Firefly III: a personal finances manager

Fix for #185

James Colea0fd4b505a02
diff --git a/app/Http/Controllers/NewUserController.php b/app/Http/Controllers/NewUserController.php
index 58a68a45fa..791d0cbfeb 100644
--- a/app/Http/Controllers/NewUserController.php
+++ b/app/Http/Controllers/NewUserController.php
@@ -107,8 +107,8 @@ class NewUserController extends Controller
$creditCard = $repository->store($creditAccount);
// store meta for CC:
- AccountMeta::create(['name' => 'ccType', 'data' => 'monthlyFull', 'account_id' => $creditCard->id,]);
- AccountMeta::create(['name' => 'ccMonthlyPaymentDate', 'data' => Carbon::now()->year . '-01-01', 'account_id' => $creditCard->id,]);
+ $repository->storeMeta($creditCard, 'ccType', 'monthlyFull');
+ $repository->storeMeta($creditCard, 'ccMonthlyPaymentDate', Carbon::now()->year . '-01-01');
}
Session::flash('success', 'New account(s) created!');
diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php
index 64ffdca545..da148f936f 100644
--- a/app/Repositories/Account/AccountRepository.php
+++ b/app/Repositories/Account/AccountRepository.php
@@ -413,6 +413,18 @@ class AccountRepository implements AccountRepositoryInterface
}
+ /**
+ * @param $account
+ * @param $name
+ * @param $value
+ *
+ * @return AccountMeta
+ */
+ public function storeMeta($account, $name, $value): AccountMeta
+ {
+ return AccountMeta::create(['name' => $name, 'data' => $value, 'account_id' => $account->id,]);
+ }
+
/**
* @return string
*/
diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.php
index cd2b8520a5..40a40d2c6d 100644
--- a/app/Repositories/Account/AccountRepositoryInterface.php
+++ b/app/Repositories/Account/AccountRepositoryInterface.php
@@ -5,6 +5,7 @@ namespace FireflyIII\Repositories\Account;
use Carbon\Carbon;
use FireflyIII\Models\Account;
+use FireflyIII\Models\AccountMeta;
use FireflyIII\Models\Preference;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
@@ -138,6 +139,15 @@ interface AccountRepositoryInterface
*/
public function store(array $data) : Account;
+ /**
+ * @param $account
+ * @param $name
+ * @param $value
+ *
+ * @return AccountMeta
+ */
+ public function storeMeta($account, $name, $value): AccountMeta;
+
/**
* @return string
*/