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

51 lines
1.3 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',
'url' => 'require|uri|unique:system',
'status' => 'require|in:0,1',
];
protected $message = [
'id.require' => '请选择系统',
'name.require' => '请填写系统名称',
'name' => '系统名称已被使用',
'url.require' => '请填写系统网址',
'url.uri' => '系统网址填写错误',
'url.unique' => '系统网址已被使用',
'status.require' => '请选择系统状态',
'status.in' => '系统状态值错误',
];
public function sceneAdd(): SystemValidate
{
return $this->only(['name','url']);
}
public function sceneEdit(): SystemValidate
{
return $this->only(['id','name','url','status']);
}
public function sceneDetail(): SystemValidate
{
return $this->only(['id']);
}
public function sceneDelete(): SystemValidate
{
return $this->only(['id']);
}
}