Update autocomplete code for #3150

This commit is contained in:
James Cole
2020-07-23 06:19:34 +02:00
parent 0f840ad082
commit 162e791dfd
16 changed files with 93 additions and 459 deletions

View File

@@ -71,12 +71,11 @@ class PiggyBankController extends Controller
$piggies = $this->piggyRepository->searchPiggyBank($data['query'], $data['limit']);
$defaultCurrency = app('amount')->getDefaultCurrency();
$response = [];
/** @var PiggyBank $piggy */
foreach ($piggies as $piggy) {
$currency = $this->accountRepository->getAccountCurrency($piggy->account) ?? $defaultCurrency;
$piggy->objectGroup = $piggy->objectGroups->first();
$piggy->name_with_amount
= $response[] = [
$response[] = [
'id' => $piggy->id,
'name' => $piggy->name,
'currency_id' => $currency->id,
@@ -104,9 +103,7 @@ class PiggyBankController extends Controller
foreach ($piggies as $piggy) {
$currency = $this->accountRepository->getAccountCurrency($piggy->account) ?? $defaultCurrency;
$currentAmount = $this->piggyRepository->getRepetition($piggy)->currentamount ?? '0';
$piggy->objectGroup = $piggy->objectGroups->first();
$piggy->name_with_amount
= $response[] = [
$response[] = [
'id' => $piggy->id,
'name' => $piggy->name,
'name_with_balance' => sprintf(