94 lines
1.7 KiB
PHP
94 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace app\adminapi\validate\custom;
|
|
|
|
use app\common\model\custom\Custom;
|
|
use app\common\model\custom\CustomContacts;
|
|
use app\common\validate\BaseValidate;
|
|
|
|
|
|
/**
|
|
* CustomContacts验证器
|
|
* Class CustomContactsValidate
|
|
* @package app\adminapi\validate\custom
|
|
*/
|
|
class CustomContactsValidate extends BaseValidate
|
|
{
|
|
|
|
/**
|
|
* 设置校验规则
|
|
* @var string[]
|
|
*/
|
|
protected $rule = [
|
|
'id' => 'require',
|
|
'custom_id' => 'require|checkCustom',
|
|
'name' => 'require',
|
|
'phone' => 'mobile|unique:' . CustomContacts::class,
|
|
'email' => 'email',
|
|
'annex' => 'checkAnnex',
|
|
];
|
|
|
|
protected $field = [
|
|
'id' => '数据id',
|
|
'custom_id' => '客户id',
|
|
'name' => '姓名',
|
|
'phone' => '手机',
|
|
'email' => '邮箱',
|
|
];
|
|
|
|
/**
|
|
* @notes 添加场景
|
|
* @return CustomContactsValidate
|
|
* @author likeadmin
|
|
* @date 2023/11/11 22:56
|
|
*/
|
|
public function sceneAdd()
|
|
{
|
|
return $this->remove('id', true);
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 编辑场景
|
|
* @return CustomContactsValidate
|
|
* @author likeadmin
|
|
* @date 2023/11/11 22:56
|
|
*/
|
|
public function sceneEdit()
|
|
{
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 删除场景
|
|
* @return CustomContactsValidate
|
|
* @author likeadmin
|
|
* @date 2023/11/11 22:56
|
|
*/
|
|
public function sceneDelete()
|
|
{
|
|
return $this->only(['id'])->remove('id', 'checkData');
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 详情场景
|
|
* @return CustomContactsValidate
|
|
* @author likeadmin
|
|
* @date 2023/11/11 22:56
|
|
*/
|
|
public function sceneDetail()
|
|
{
|
|
return $this->only(['id']);
|
|
}
|
|
|
|
public function checkCustom($value): bool|string
|
|
{
|
|
$custom = Custom::where('id', $value)->findOrEmpty();
|
|
if ($custom->isEmpty()) {
|
|
return '客户信息不存在';
|
|
}
|
|
return true;
|
|
}
|
|
|
|
} |