Add some custom order.

This commit is contained in:
James Cole
2020-08-02 18:25:09 +02:00
parent 9a4a2708c0
commit 8dd315d7d6

View File

@@ -61,7 +61,7 @@ class AccountController extends Controller
return $next($request); 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); return response()->json($return);
} }
} }