diff --git a/Base/Model.php b/Base/Model.php index c0501be..0e7945b 100644 --- a/Base/Model.php +++ b/Base/Model.php @@ -49,7 +49,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \ /** @var null|string */ - protected ?string $primary = NULL; + protected string $primary = ''; /** @@ -187,17 +187,17 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \ */ public function hasPrimary(): bool { - return !empty($this->primary); + return $this->primary != ''; } /** * @return null|string * @throws */ - public function getPrimary(): ?string + public function getPrimary(): string { if (!$this->hasPrimary()) { - return NULL; + return ''; } return $this->primary; } @@ -222,10 +222,11 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \ */ public function getPrimaryValue(): ?int { - if (!$this->hasPrimary()) { + if ($this->hasPrimary()) { + return (int)$this->_oldAttributes[$this->getPrimary()] ?? null; + } else { return null; } - return $this->_oldAttributes[$this->getPrimary()] ?? null; } /**