eee
This commit is contained in:
+7
-6
@@ -49,7 +49,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \
|
|||||||
|
|
||||||
|
|
||||||
/** @var null|string */
|
/** @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
|
public function hasPrimary(): bool
|
||||||
{
|
{
|
||||||
return !empty($this->primary);
|
return $this->primary != '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return null|string
|
* @return null|string
|
||||||
* @throws
|
* @throws
|
||||||
*/
|
*/
|
||||||
public function getPrimary(): ?string
|
public function getPrimary(): string
|
||||||
{
|
{
|
||||||
if (!$this->hasPrimary()) {
|
if (!$this->hasPrimary()) {
|
||||||
return NULL;
|
return '';
|
||||||
}
|
}
|
||||||
return $this->primary;
|
return $this->primary;
|
||||||
}
|
}
|
||||||
@@ -222,10 +222,11 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, \
|
|||||||
*/
|
*/
|
||||||
public function getPrimaryValue(): ?int
|
public function getPrimaryValue(): ?int
|
||||||
{
|
{
|
||||||
if (!$this->hasPrimary()) {
|
if ($this->hasPrimary()) {
|
||||||
|
return (int)$this->_oldAttributes[$this->getPrimary()] ?? null;
|
||||||
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return $this->_oldAttributes[$this->getPrimary()] ?? null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user