'defaultAsset'], ['accountRole' => 'savingAsset',], ['accountRole' => 'sharedAsset',], ['accountRole' => 'ccAsset', 'ccMonthlyPaymentDate' => '2015-05-27', 'ccType' => 'monthlyFull',], ['accountRole' => 'savingAsset',], ['accountRole' => 'savingAsset',], ]; foreach ($assets as $index => $name) { // create account: $account = Account::create( [ 'user_id' => $user->id, 'account_type_id' => 3, 'name' => $name, 'active' => 1, 'encrypted' => 1, 'iban' => $ibans[$index], ] ); foreach ($assetMeta[$index] as $name => $value) { AccountMeta::create(['account_id' => $account->id, 'name' => $name, 'data' => $value,]); } } } /** * @param User $user */ public static function createBills(User $user) { Bill::create( [ 'name' => 'Rent', 'match' => 'rent,land,lord', 'amount_min' => 795, 'amount_max' => 805, 'user_id' => $user->id, 'date' => '2015-01-01', 'active' => 1, 'automatch' => 1, 'repeat_freq' => 'monthly', 'skip' => 0, ] ); Bill::create( [ 'name' => 'Health insurance', 'match' => 'zilveren,kruis,health', 'amount_min' => 120, 'amount_max' => 140, 'user_id' => $user->id, 'date' => '2015-01-01', 'active' => 1, 'automatch' => 1, 'repeat_freq' => 'monthly', 'skip' => 0, ] ); } /** * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @param User $user */ public static function createPiggybanks(User $user) { $account = self::findAccount($user, 'TestData Savings'); $camera = PiggyBank::create( [ 'account_id' => $account->id, 'name' => 'New camera', 'targetamount' => 1000, 'startdate' => '2015-04-01', 'reminder_skip' => 0, 'remind_me' => 0, 'order' => 1, ] ); $repetition = $camera->piggyBankRepetitions()->first(); $repetition->currentamount = 735; $repetition->save(); // events: PiggyBankEvent::create( [ 'piggy_bank_id' => $camera->id, 'date' => '2015-05-01', 'amount' => '245', ] ); PiggyBankEvent::create( [ 'piggy_bank_id' => $camera->id, 'date' => '2015-06-01', 'amount' => '245', ] ); PiggyBankEvent::create( [ 'piggy_bank_id' => $camera->id, 'date' => '2015-07-01', 'amount' => '245', ] ); $phone = PiggyBank::create( [ 'account_id' => $account->id, 'name' => 'New phone', 'targetamount' => 600, 'startdate' => '2015-04-01', 'reminder_skip' => 0, 'remind_me' => 0, 'order' => 2, ] ); $repetition = $phone->piggyBankRepetitions()->first(); $repetition->currentamount = 333; $repetition->save(); // events: PiggyBankEvent::create( [ 'piggy_bank_id' => $phone->id, 'date' => '2015-05-01', 'amount' => '111', ] ); PiggyBankEvent::create( [ 'piggy_bank_id' => $phone->id, 'date' => '2015-06-01', 'amount' => '111', ] ); PiggyBankEvent::create( [ 'piggy_bank_id' => $phone->id, 'date' => '2015-07-01', 'amount' => '111', ] ); $couch = PiggyBank::create( [ 'account_id' => $account->id, 'name' => 'New couch', 'targetamount' => 500, 'startdate' => '2015-04-01', 'reminder_skip' => 0, 'remind_me' => 0, 'order' => 3, ] ); $repetition = $couch->piggyBankRepetitions()->first(); $repetition->currentamount = 120; $repetition->save(); // events: PiggyBankEvent::create( [ 'piggy_bank_id' => $couch->id, 'date' => '2015-05-01', 'amount' => '40', ] ); PiggyBankEvent::create( [ 'piggy_bank_id' => $couch->id, 'date' => '2015-06-01', 'amount' => '40', ] ); PiggyBankEvent::create( [ 'piggy_bank_id' => $couch->id, 'date' => '2015-07-01', 'amount' => '40', ] ); // empty one. PiggyBank::create( [ 'account_id' => $account->id, 'name' => 'New head set', 'targetamount' => 500, 'startdate' => '2015-04-01', 'reminder_skip' => 0, 'remind_me' => 0, 'order' => 4, ] ); } /** * @param User $user * @param $name * * @return Account|null */ public static function findAccount(User $user, $name) { /** @var Account $account */ foreach ($user->accounts()->get() as $account) { if ($account->name == $name) { Log::debug('Trying to find "' . $name . '" in "' . $account->name . '", and found it!'); return $account; } Log::debug('Trying to find "' . $name . '" in "' . $account->name . '".'); } return null; } }