Fix bug: unable to set currency rate with Postgres

This commit is contained in:
Frederic Guillot
2016-01-14 20:40:31 -05:00
parent 805be7d331
commit a8f404421f
5 changed files with 77 additions and 2 deletions

View File

@@ -42,7 +42,7 @@ class Currency extends Base
$reference = $this->config->get('application_currency', 'USD');
if ($reference !== $currency) {
$rates = $rates === null ? $this->db->hashtable(self::TABLE)->getAll('currency', 'rate') : array();
$rates = $rates === null ? $this->db->hashtable(self::TABLE)->getAll('currency', 'rate') : $rates;
$rate = isset($rates[$currency]) ? $rates[$currency] : 1;
return $rate * $price;
@@ -65,7 +65,7 @@ class Currency extends Base
return $this->update($currency, $rate);
}
return $this->persist(self::TABLE, compact('currency', 'rate'));
return $this->db->table(self::TABLE)->insert(array('currency' => $currency, 'rate' => $rate));
}
/**