This commit is contained in:
2023-08-17 17:33:28 +08:00
parent c30c830169
commit 05f90fe4a4
+4 -1
View File
@@ -188,7 +188,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T
*/
public function hasPrimary(): bool
{
return $this->primary !== NULL && $this->primary !== '';
return !empty($this->primary);
}
/**
@@ -223,6 +223,9 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T
*/
public function getPrimaryValue(): ?int
{
if (!$this->hasPrimary()) {
return null;
}
return $this->_oldAttributes[$this->getPrimary()] ?? null;
}