更新目录结构
This commit is contained in:
59
app/http/validate/admin/Content.php
Normal file
59
app/http/validate/admin/Content.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\http\validate\admin;
|
||||
|
||||
use think\Validate;
|
||||
use think\facade\Request;
|
||||
use app\model\Attribute;
|
||||
|
||||
/**
|
||||
* 菜单验证
|
||||
*/
|
||||
class Content extends Validate{
|
||||
protected $rule = [];
|
||||
|
||||
protected $message = [];
|
||||
|
||||
protected $scene = [];
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$param = Request::param();
|
||||
$map = [];
|
||||
|
||||
$map[] = ['model_id', '=', $param['model_id']];
|
||||
if ($param['function'] == 'add') {
|
||||
$map[] = ['is_show', 'IN', [1, 2]];
|
||||
}else if ($param['function'] == 'edit') {
|
||||
$map[] = ['is_show', 'IN', [1, 3]];
|
||||
}
|
||||
|
||||
$attr = Attribute::where($map)->select();
|
||||
$rule = [];
|
||||
$message = [];
|
||||
$field = [];
|
||||
foreach ($attr as $value) {
|
||||
if ($value['is_must']) {
|
||||
$rule[$value['name']] = 'require';
|
||||
$message[$value['name'].'.require'] = $value['title'] . '不能为空!';
|
||||
$field[] = $value['name'];
|
||||
}
|
||||
}
|
||||
$this->rule = $rule;
|
||||
|
||||
$this->message = $message;
|
||||
|
||||
$this->scene = [
|
||||
'add' => $field,
|
||||
'edit' => $field,
|
||||
'useradd' => $field,
|
||||
'useredit' => $field,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user