/** * Returns a multidimensional array of each center and each * account that the center has, along with the balance * of that account. * * @return array */ public static function getSeparateCenterAccounts($center_id = false) { $center_list_accounts = []; if ($center_id) { $centers = self::getCenter($center_id); } else { $centers = self::getCenter(); } for ($i = 0; $i < count($centers); $i++) { $center_list_accounts[$i]['center_name'] = $centers[$i]->name; $center_list_accounts[$i]['center_id'] = $centers[$i]->id; $center_list_accounts[$i]['accounts'] = []; $counter = 0; foreach ($centers[$i]->centers as $item) { $account_standing = 'black'; $account = Balance::getMonthlyBalance(Balance::getClosestRealTransaction(Carbon::now()->toDateString()), $item->id); $center_list_accounts[$i]['accounts'][$counter]['account_id'] = $item->id; $center_list_accounts[$i]['accounts'][$counter]['account_name'] = $account['center_name']; $center_list_accounts[$i]['accounts'][$counter]['balance'] = $account['balance']; if ($account['balance']->availableBalance < 0) { $account_standing = 'red'; } $center_list_accounts[$i]['accounts'][$counter]['standing'] = $account_standing; $counter++; } } return $center_list_accounts; }
/** * Gets the monthly of an individual center instead of all of the accounts. * * * @param $center_id * @return array|string */ public function getCenterMonthlyBalance($center_id) { return Balance::getMonthlyBalance(false, $center_id); }