engineering/app/adminapi/validate/supervision_work/SupervisionMaterialEntryDetailValidate.php
2024-02-28 16:01:52 +08:00

128 lines
3.5 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_work;
use app\common\model\supervision_work\SupervisionMaterialEntry;
use app\common\model\supervision_work\SupervisionMaterialEntryDetail;
use app\common\validate\BaseValidate;
/**
* 工程监理--材料进场明细验证器
* Class SupervisionMaterialEntryDetailValidate
* @package app\adminapi\validate\supervision_work
*/
class SupervisionMaterialEntryDetailValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require|checkData',
'material_entry_id' => 'require|checkMaterialEntry',
'name' => 'require',
'brand' => 'require',
'model' => 'require',
'unit' => 'require',
'contract_brand' => 'require|in:0,1',
'entry_number' => 'require|float',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'material_entry_id' => '材料进场id',
'name' => '材料名称',
'brand' => '材料品牌',
'model' => '材料型号',
'unit' => '计数单位',
'contract_brand' => '合同约定品牌',
'entry_number' => '进场数量',
];
/**
* @notes 添加场景
* @return SupervisionMaterialEntryDetailValidate
* @author likeadmin
* @date 2024/02/28 13:41
*/
public function sceneAdd()
{
return $this->only(['material_entry_id','name','brand','model','unit','contract_brand','entry_number']);
}
/**
* @notes 编辑场景
* @return SupervisionMaterialEntryDetailValidate
* @author likeadmin
* @date 2024/02/28 13:41
*/
public function sceneEdit()
{
return $this->only(['id','material_entry_id','name','brand','model','unit','contract_brand','entry_number']);
}
/**
* @notes 删除场景
* @return SupervisionMaterialEntryDetailValidate
* @author likeadmin
* @date 2024/02/28 13:41
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return SupervisionMaterialEntryDetailValidate
* @author likeadmin
* @date 2024/02/28 13:41
*/
public function sceneDetail()
{
return $this->only(['id']);
}
public function checkData($value): bool|string
{
$data = SupervisionMaterialEntryDetail::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '数据不存在';
}
return true;
}
public function checkMaterialEntry($value): bool|string
{
$data = SupervisionMaterialEntry::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '材料进场信息不存在';
}
return true;
}
}