改名
This commit is contained in:
+10
-9
@@ -13,12 +13,10 @@ defined('SAVE_FAIL') or define('SAVE_FAIL', 3227);
|
||||
defined('FIND_OR_CREATE_MESSAGE') or define('FIND_OR_CREATE_MESSAGE', 'Create a new model, but the data cannot be empty.');
|
||||
|
||||
|
||||
use Annotation\Inject;
|
||||
use ArrayAccess;
|
||||
use Closure;
|
||||
use Database\ActiveQuery;
|
||||
use Database\Connection;
|
||||
use Database\HasCount;
|
||||
use Database\HasMany;
|
||||
use Database\HasOne;
|
||||
use Database\ModelInterface;
|
||||
@@ -98,12 +96,6 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T
|
||||
protected string $connection = 'db';
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected array $rules = [];
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
@@ -119,6 +111,15 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
@@ -611,7 +612,7 @@ abstract class Model extends Component implements ModelInterface, ArrayAccess, T
|
||||
if (!is_null($data)) {
|
||||
$this->_attributes = merge($this->_attributes, $data);
|
||||
}
|
||||
if (!$this->validator($this->rules) || !$this->beforeSave($this)) {
|
||||
if (!$this->validator($this->rules()) || !$this->beforeSave($this)) {
|
||||
return false;
|
||||
}
|
||||
[$change, $condition, $fields] = $this->separation();
|
||||
|
||||
Reference in New Issue
Block a user