This commit is contained in:
2021-03-15 17:41:39 -03:00
parent ddea78a30a
commit 5921890ee7
2 changed files with 52 additions and 0 deletions

20
src/Currency.php Normal file
View File

@ -0,0 +1,20 @@
<?php
namespace ProVM\Money;
use ProVM\Common\Alias\Model;
/**
* @property int $id
* @property string $code
* @property string $name
*/
class Currency extends Model {
public static $_table = 'currencies';
protected $values;
public function values(): ?array {
if ($this->values === null) {
$this->values = $this->parentOf(Value::class, [Model::CHILD_KEY => 'currency_id']);
}
}
}

32
src/Value.php Normal file
View File

@ -0,0 +1,32 @@
<?php
namespace ProVM\Money;
use ProVM\Common\Alias\Model;
use ProVM\Common\Define\Model\DateTime;
/**
* @property Currency $currency_id
* @property \DateTime $date_time
* @property double $value
* @property Currency $base_id
*/
class Value {
use DateTime;
public static $_table = 'values';
protected $currency;
public function currency(): ?Currency {
if ($this->currency === null) {
$this->currency = $this->childOf(Currency::class, [Model::SELF_KEY => 'currency_id']);
}
return $this->currency;
}
protected $base;
public function base(): ?Currency {
if ($this->base === null) {
$this->base = $this->childOf(Currency::class, [Model::SELF_KEY => 'base_id']);
}
return $this->base;
}
}