engineering/app/adminapi/validate/supervision_qualification_review/SupervisionSpecialOperationPersonnelValidate.php
2024-02-26 15:19:56 +08:00

137 lines
3.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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\supervision_qualification_review;
use app\common\model\supervision_qualification_review\SupervisionParticipatingUnitsQualifications;
use app\common\model\supervision_qualification_review\SupervisionSpecialOperationPersonnel;
use app\common\validate\BaseValidate;
/**
* 工程监理--特种作业人员资质验证器
* Class SupervisionSpecialOperationPersonnelValidate
* @package app\adminapi\validate\supervision_qualification_review
*/
class SupervisionSpecialOperationPersonnelValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require|checkData',
'unit_qualification_id' => 'require|checkUnitQualification',
'name' => 'require',
'id_card' => 'idCard',
'validity_period' => 'dateFormat:Y-m-d',
'enter_time' => 'dateFormat:Y-m-d H:i:s',
'leave_time' => 'dateFormat:Y-m-d H:i:s',
'status' => 'in:0,1',
'annex' => 'checkAnnex',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'unit_qualification_id' => '参建单位资质id',
'name' => '姓名',
'work_type' => '工种',
'id_card' => '身份证',
'validity_period' => '资格有效期',
'enter_time' => '进场时间',
'leave_time' => '离场时间',
'status' => '状态',
'remark' => '备注',
'create_user' => '创建人',
];
/**
* @notes 添加场景
* @return SupervisionSpecialOperationPersonnelValidate
* @author likeadmin
* @date 2024/02/26 11:45
*/
public function sceneAdd()
{
return $this->remove('id',true);
}
/**
* @notes 编辑场景
* @return SupervisionSpecialOperationPersonnelValidate
* @author likeadmin
* @date 2024/02/26 11:45
*/
public function sceneEdit()
{}
/**
* @notes 删除场景
* @return SupervisionSpecialOperationPersonnelValidate
* @author likeadmin
* @date 2024/02/26 11:45
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return SupervisionSpecialOperationPersonnelValidate
* @author likeadmin
* @date 2024/02/26 11:45
*/
public function sceneDetail()
{
return $this->only(['id']);
}
public function checkData($value): bool|string
{
$data = SupervisionSpecialOperationPersonnel::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '数据不存在';
}
return true;
}
public function checkUnitQualification($value): bool|string
{
$data = SupervisionParticipatingUnitsQualifications::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '参建单位资质信息不存在';
}
return true;
}
public function checkAnnex($value): bool|string
{
if(!empty($value) && $value != '' && !is_array($value)){
return '附件格式错误';
}
return true;
}
}