|
|
@ -222,8 +222,7 @@ abstract class Model { |
|
|
|
|
|
|
|
|
|
|
|
// Set other attributes |
|
|
|
// Set other attributes |
|
|
|
foreach ($this->getAttributes() as $attribute) { |
|
|
|
foreach ($this->getAttributes() as $attribute) { |
|
|
|
if (_exists($fill, $attribute) || |
|
|
|
if (isset($fill[$attribute])) { |
|
|
|
(isset($fill[$attribute]) && $fill[$attribute] === '0')) { |
|
|
|
|
|
|
|
// Escape sequences are only interpreted with double quotes! |
|
|
|
// Escape sequences are only interpreted with double quotes! |
|
|
|
$this->{$attribute} = preg_replace('/\r\n?/', "\n", $fill[$attribute]); |
|
|
|
$this->{$attribute} = preg_replace('/\r\n?/', "\n", $fill[$attribute]); |
|
|
|
} |
|
|
|
} |
|
|
@ -232,6 +231,27 @@ abstract class Model { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function validate(): bool |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
foreach ($this->getAttributes() as $attribute) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$required = false; |
|
|
|
|
|
|
|
foreach ($this->rules as $rule) { |
|
|
|
|
|
|
|
if ($rule[0] == $attribute && $rule[2] == 1) { |
|
|
|
|
|
|
|
$required = true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Exit if rule is marked 'required' but empty, "0" is not empty! |
|
|
|
|
|
|
|
if ($required && empty($this->{$attribute}) && $this->{$attribute} !== "0") { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getPrimaryKey(): string |
|
|
|
public function getPrimaryKey(): string |
|
|
|
{ |
|
|
|
{ |
|
|
|
return $this->primaryKey; |
|
|
|
return $this->primaryKey; |
|
|
|