engineering/app/adminapi/validate/project/ProjectCostTempSetValidate.php
2023-12-14 14:14:24 +08:00

120 lines
3.2 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\project;
use app\common\model\project\ProjectCostTempSet;
use app\common\model\project\ProjectTypeSet;
use app\common\validate\BaseValidate;
/**
* 项目费用模板验证器
* Class ProjectCostTempSetValidate
* @package app\adminapi\validate\project
*/
class ProjectCostTempSetValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require',
'project_type_id' => 'require|checkProjectType',
'subject_code' => 'require|unique:'.ProjectCostTempSet::class,
'first_level_subject' => 'require',
'is_travel' => 'require|integer|in:1,2',
];
protected $message = [
'id.require' => '缺少你要参数',
'project_type_id.require' => '请选择项目类型',
'subject_code.require' => '请填写科目编码',
'subject_code.unique' => '科目编码不能重复',
'first_level_subject' => '请填写一级科目',
'is_travel.require' => '请选择是否是差旅科目',
'is_travel.integer' => '差旅科目数据格式错误',
'is_travel.in' => '差旅科目数据值错误'
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'project_type_id' => '项目类型id',
'subject_code' => '科目编码',
'first_level_subject' => '一级科目',
'is_travel' => '是否是差旅科目 1-是 2-否',
];
/**
* @notes 添加场景
* @return ProjectCostTempSetValidate
* @author likeadmin
* @date 2023/12/14 11:54
*/
public function sceneAdd()
{
return $this->remove('id',true);
}
/**
* @notes 编辑场景
* @return ProjectCostTempSetValidate
* @author likeadmin
* @date 2023/12/14 11:54
*/
public function sceneEdit()
{}
/**
* @notes 删除场景
* @return ProjectCostTempSetValidate
* @author likeadmin
* @date 2023/12/14 11:54
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return ProjectCostTempSetValidate
* @author likeadmin
* @date 2023/12/14 11:54
*/
public function sceneDetail()
{
return $this->only(['id']);
}
public function checkProjectType($value): bool|string
{
$data = ProjectTypeSet::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '项目类型不存在';
}
return true;
}
}