data_center/app/common/validate/systems/SystemValidate.php

57 lines
1.6 KiB
PHP

<?php
namespace app\common\validate\systems;
use app\common\validate\BaseValidate;
class SystemValidate extends BaseValidate
{
protected $regex = [
'uri' => '^((https?):\/\/)((?:www\.)|([a-z0-9-_]+\.))?[a-z0-9-_]+(?:\.[a-z]{2,})+(?:\/.*)?$',
];
protected $rule = [
'id' => 'require',
'name' => 'require|unique:system',
'icon' => 'require',
'app_version' => 'require',
'down_url' => 'require',
'url' => 'require|uri|unique:system',
'status' => 'require|in:0,1',
'register_status' => 'require|in:0,1',
];
protected $message = [
'id.require' => '请选择系统',
'name.require' => '请填写系统名称',
'name' => '系统名称已被使用',
'url.require' => '请填写系统网址',
'url.uri' => '系统网址填写错误',
'url.unique' => '系统网址已被使用',
'status.require' => '请选择系统状态',
'status.in' => '系统状态值错误',
'register_status.require' => '请选择系统注册状态',
'register_status.in' => '系统注册状态值错误',
];
public function sceneAdd(): SystemValidate
{
return $this->only(['name','icon','app_version','down_url','url','status','register_status']);
}
public function sceneEdit(): SystemValidate
{
return $this->only(['id','name','icon','app_version','down_url','url','status','register_status']);
}
public function sceneDetail(): SystemValidate
{
return $this->only(['id']);
}
public function sceneDelete(): SystemValidate
{
return $this->only(['id']);
}
}