36 lines
751 B
PHP
36 lines
751 B
PHP
<?php
|
|
|
|
namespace common\core;
|
|
use yii\base\Exception;
|
|
use yii\base\Model;
|
|
|
|
/**
|
|
* ---------------------------------------
|
|
* 框架核心扩展模型,所有表单模型都继承自该类
|
|
* ---------------------------------------
|
|
*/
|
|
|
|
class BaseModel extends Model {
|
|
|
|
protected $sign = '';
|
|
/**
|
|
* ActiveRecord 数据验证,返回第一条错误验证
|
|
* @param array $model
|
|
* @return string
|
|
*/
|
|
public function getErrorMsg($model = null)
|
|
{
|
|
if (!$model) {
|
|
$model = $this;
|
|
}
|
|
$msg = isset($model->errors) ? current($model->errors)[0] : '数据异常!';
|
|
return $msg;
|
|
}
|
|
|
|
public function setSign($val)
|
|
{
|
|
$this->sign = $val;
|
|
return $this;
|
|
}
|
|
}
|