124 lines
3.1 KiB
PHP
124 lines
3.1 KiB
PHP
<?php
|
||
// +----------------------------------------------------------------------
|
||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||
// +----------------------------------------------------------------------
|
||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||
// | 开源版本可自由商用,可去除界面版权logo
|
||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||
// | 访问官网:https://www.likeadmin.cn
|
||
// | likeadmin团队 版权所有 拥有最终解释权
|
||
// +----------------------------------------------------------------------
|
||
// | author: likeadminTeam
|
||
// +----------------------------------------------------------------------
|
||
|
||
namespace app\adminapi\validate\marketing;
|
||
|
||
|
||
use app\common\model\marketing\MarketingCustom;
|
||
use app\common\model\marketing\MarketingCustomContacts;
|
||
use app\common\validate\BaseValidate;
|
||
|
||
|
||
/**
|
||
* 市场经营--客户信息--联系人验证器
|
||
* Class MarketingCustomContactsValidate
|
||
* @package app\adminapi\validate\marketing
|
||
*/
|
||
class MarketingCustomContactsValidate extends BaseValidate
|
||
{
|
||
|
||
/**
|
||
* 设置校验规则
|
||
* @var string[]
|
||
*/
|
||
protected $rule = [
|
||
'id' => 'require|checkData',
|
||
'custom_id' => 'require|checkCustom',
|
||
'name' => 'require',
|
||
'gender' => 'in:0,1',
|
||
'mobile' => 'mobile',
|
||
'email' => 'email',
|
||
];
|
||
|
||
|
||
/**
|
||
* 参数描述
|
||
* @var string[]
|
||
*/
|
||
protected $field = [
|
||
'id' => 'id',
|
||
'custom_id' => '客户id',
|
||
'name' => '姓名',
|
||
'dept' => '部门',
|
||
'gender' => '姓名 0-男 1-女',
|
||
'job' => '职务',
|
||
'mobile' => '手机',
|
||
'telephone' => '电话',
|
||
'email' => '邮箱',
|
||
'qq' => 'QQ',
|
||
'remark' => '备注',
|
||
|
||
];
|
||
|
||
|
||
/**
|
||
* @notes 添加场景
|
||
* @return MarketingCustomContactsValidate
|
||
* @author likeadmin
|
||
* @date 2024/04/01 14:26
|
||
*/
|
||
public function sceneAdd()
|
||
{
|
||
return $this->only(['custom_id', 'name', 'dept', 'gender', 'job', 'mobile', 'telephone', 'email', 'qq', 'remark']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 编辑场景
|
||
* @return MarketingCustomContactsValidate
|
||
* @author likeadmin
|
||
* @date 2024/04/01 14:26
|
||
*/
|
||
public function sceneEdit()
|
||
{
|
||
return $this->only(['id', 'custom_id', 'name', 'dept', 'gender', 'job', 'mobile', 'telephone', 'email', 'qq', 'remark']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 删除场景
|
||
* @return MarketingCustomContactsValidate
|
||
* @author likeadmin
|
||
* @date 2024/04/01 14:26
|
||
*/
|
||
public function sceneDelete()
|
||
{
|
||
return $this->only(['id'])->remove('id', 'checkData');
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 详情场景
|
||
* @return MarketingCustomContactsValidate
|
||
* @author likeadmin
|
||
* @date 2024/04/01 14:26
|
||
*/
|
||
public function sceneDetail()
|
||
{
|
||
return $this->only(['id']);
|
||
}
|
||
|
||
public function checkData($value): bool|string
|
||
{
|
||
$data = MarketingCustomContacts::where('id', $value)->findOrEmpty();
|
||
return $data->isEmpty() ? '数据不存在' : true;
|
||
}
|
||
|
||
public function checkCustom($value): bool|string
|
||
{
|
||
$data = MarketingCustom::where('id', $value)->findOrEmpty();
|
||
return $data->isEmpty() ? '客户信息不存在' : true;
|
||
}
|
||
|
||
} |