初始化仓库
This commit is contained in:
35
common/core/BaseModel.php
Normal file
35
common/core/BaseModel.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user