This commit is contained in:
2021-03-19 22:49:09 -03:00
parent ec44b0281e
commit 99c18cb871
8 changed files with 45 additions and 11 deletions

View File

@ -16,9 +16,21 @@ class Currency extends Model {
public function values(): ?array {
if ($this->values === null) {
$this->values = $this->parentOf(Value::class, [Model::CHILD_KEY => 'currency_id']);
if ($this->values) {
usort($this->values, function($a, $b) {
return $b->dateTime()->timestamp - $a->dateTime()->timestamp;
});
}
}
return $this->values;
}
protected $latest;
public function latest(): ?Value {
if ($this->latest === null) {
$this->latest = $this->values()[0];
}
return $this->latest;
}
protected static $fields = ['code', 'name'];
public static function add(ModelFactory $factory, $info) {