59 lines
1.7 KiB
PHP
Executable File
59 lines
1.7 KiB
PHP
Executable File
<?php
|
|
|
|
namespace app\adminapi\validate\doctor;
|
|
|
|
use app\common\validate\BaseValidate;
|
|
|
|
/**
|
|
* 药品库验证器
|
|
*/
|
|
class MedicineValidate extends BaseValidate
|
|
{
|
|
protected $rule = [
|
|
'id' => 'require|integer',
|
|
'name' => 'require|max:100',
|
|
'supplier' => 'require|max:100',
|
|
'unit' => 'require|max:20',
|
|
'settlement_price' => 'require|float|>=:0',
|
|
'retail_price' => 'require|float|>=:0',
|
|
'stock' => 'integer|>=:0',
|
|
'image' => 'max:255',
|
|
'status' => 'in:0,1',
|
|
'remark' => 'max:500',
|
|
];
|
|
|
|
protected $message = [
|
|
'id.require' => '药品ID不能为空',
|
|
'name.require' => '药材名称不能为空',
|
|
'name.max' => '药材名称不能超过100个字符',
|
|
'supplier.require' => '供应商名称不能为空',
|
|
'supplier.max' => '供应商名称不能超过100个字符',
|
|
'unit.require' => '单位不能为空',
|
|
'settlement_price.require' => '结算价不能为空',
|
|
'settlement_price.float' => '结算价必须是数字',
|
|
'retail_price.require' => '零售价不能为空',
|
|
'retail_price.float' => '零售价必须是数字',
|
|
'stock.integer' => '库存必须是整数',
|
|
];
|
|
|
|
public function sceneAdd()
|
|
{
|
|
return $this->only(['name', 'supplier', 'unit', 'settlement_price', 'retail_price', 'stock', 'image', 'status', 'remark']);
|
|
}
|
|
|
|
public function sceneEdit()
|
|
{
|
|
return $this->only(['id', 'name', 'supplier', 'unit', 'settlement_price', 'retail_price', 'stock', 'image', 'status', 'remark']);
|
|
}
|
|
|
|
public function sceneDelete()
|
|
{
|
|
return $this->only(['id']);
|
|
}
|
|
|
|
public function sceneDetail()
|
|
{
|
|
return $this->only(['id']);
|
|
}
|
|
}
|