Add some custom order.

This commit is contained in:
James Cole 2020-08-02 18:25:09 +02:00
parent 9a4a2708c0
commit 8dd315d7d6
No known key found for this signature in database
GPG Key ID: B5669F9493CDE38D

View File

@ -61,7 +61,7 @@ class AccountController extends Controller
return $next($request);
}
);
$this->balanceTypes = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE, ];
$this->balanceTypes = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE,];
}
/**
@ -104,6 +104,16 @@ class AccountController extends Controller
];
}
// custom order.
$order = [AccountType::ASSET, AccountType::REVENUE, AccountType::EXPENSE];
usort($return, function ($a, $b) use ($order) {
$pos_a = array_search($a['type'], $order);
$pos_b = array_search($b['type'], $order);
return $pos_a - $pos_b;
});
return response()->json($return);
}
}