| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 | <?phpnamespace app\admin\validate\life;use support\Validate;class HealthyFoodValidate extends Validate{    protected $rule = [        'food_id' => 'require|integer',        'food_category_id' => 'require|integer',        'food_shop_id' => 'require|integer',        'food_postage_id' => 'require|integer',        'food_name' => 'require|regex:/^[\x{4e00}-\x{9fa5}a-zA-Z0-9\_\-\,\s]+$/u',        'food_img' => 'regex:/^[0-9a-zA-Z\/\.]+$/',        'food_slide' => 'regex:/^[0-9a-zA-Z\/\.\,]+$/',        'food_price' => 'require|float',        'food_sell_num' => 'integer',        'food_pack_price' => 'float',        'food_materials' => 'isJson',        'food_condiment' => 'isJson',        'food_type' => 'require|integer',        'food_storage' => 'require',        'food_packaging' => 'require',        'food_varieties' => 'require',        'food_cater_time' => 'date',        'food_cater_type' => 'integer',        'food_week' => 'regex:/^[0-9\,]+$/',        'food_attr' => 'require',        'food_package' => 'regex:/^[0-9\,]+$/',        'food_package_num' => 'integer',        'food_label' => 'regex:/^[\x{4e00}-\x{9fa5}a-zA-Z0-9\_\-\,\s]+$/u',        'food_weight' => 'float',        'food_status' => 'in:0,1'    ];    protected $message = [];    protected $scene = [        'add' => ['food_category_id', 'food_shop_id', 'food_postage_id', 'food_name', 'food_img', 'food_slide', 'food_price', 'food_sell_num',            'food_pack_price', 'food_materials', 'food_condiment', 'food_type', 'food_storage', 'food_packaging', 'food_varieties',            'food_cater_time', 'food_cater_type', 'food_week', 'food_attr', 'food_package', 'food_package_num', 'food_label', 'food_weight'],        'update' => ['food_id', 'food_category_id', 'food_shop_id', 'food_postage_id', 'food_name', 'food_img', 'food_slide', 'food_price',            'food_sell_num', 'food_pack_price', 'food_materials', 'food_condiment', 'food_type', 'food_storage', 'food_packaging', 'food_varieties',            'food_cater_time', 'food_cater_type', 'food_week', 'food_attr', 'food_package', 'food_package_num', 'food_label', 'food_weight'],    ];    protected function isJson($value)    {        if (is_json($value)) {            return true;        }        return '数据格式错误~';    }}
 |