diff --git a/src/Currency.php b/src/Currency.php index bedadd7..02cf51f 100644 --- a/src/Currency.php +++ b/src/Currency.php @@ -31,6 +31,13 @@ class Currency extends Model { } return $this->latest; } + protected $sources; + public function sources(): ?array { + if ($this->sources === null) { + $this->sources = $this->parentOf(Source::class, [Model::CHILD_KEY => 'currency_id']); + } + return $this->sources; + } protected static $fields = ['code', 'name']; public static function add(ModelFactory $factory, $info) { @@ -49,7 +56,7 @@ class Currency extends Model { protected function checkCode(string $code): bool { return ($this->find(Currency::class)->where([['code', $code]])->one()) ? true : false; } - public function edit($info) { + public function edit($info): bool { $data = array_intersect_key((array) $info, array_combine(self::$fields, self::$fields)); $edited = false; foreach ($data as $field => $value) { diff --git a/src/Source.php b/src/Source.php new file mode 100644 index 0000000..a271cb2 --- /dev/null +++ b/src/Source.php @@ -0,0 +1,27 @@ +currency === null) { + $this->currency = $this->childOf(Currency::class, [Model::SELF_KEY => 'currency_id']); + } + return $this->currency; + } + public function frecuency(\DateInterval $frecuency = null) { + if ($frecuency == null) { + return new \CarbonInterval($this->fecuency); + } + $this->frecuency = CarbonInterval::getDateIntervalSpec($frecuency); + } +} diff --git a/src/Value.php b/src/Value.php index 66824aa..4c51532 100644 --- a/src/Value.php +++ b/src/Value.php @@ -46,7 +46,7 @@ class Value extends Model { $result->value = $value->asArray(); return $result; } - public function edit($info) { + public function edit($info): bool { $data = array_intersect_key((array) $info, array_combine(self::$fields, self::$fields)); $edited = false; foreach ($data as $field => $value) {