From 22a04814dc802f79e8c61ae27f901050f5455956 Mon Sep 17 00:00:00 2001 From: whwyy Date: Fri, 22 Dec 2023 11:41:24 +0800 Subject: [PATCH] eee --- Base/Model.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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; } /**