/** * @param array $data * * @return array */ private function storeWithdrawalAccounts(array $data) : array { $sourceAccount = Account::where('user_id', $this->user->id)->where('id', $data['source_account_id'])->first(['accounts.*']); if (strlen($data['destination_account_name']) > 0) { $destinationType = AccountType::where('type', 'Expense account')->first(); $destinationAccount = Account::firstOrCreateEncrypted(['user_id' => $data['user'], 'account_type_id' => $destinationType->id, 'name' => $data['destination_account_name'], 'active' => 1]); return [$sourceAccount, $destinationAccount]; } $destinationType = AccountType::where('type', 'Cash account')->first(); $destinationAccount = Account::firstOrCreateEncrypted(['user_id' => $data['user'], 'account_type_id' => $destinationType->id, 'name' => 'Cash account', 'active' => 1]); return [$sourceAccount, $destinationAccount]; }