<?php
namespace app\admin\validate\life;

use think\Validate;

class FoodValidate extends Validate
{
    protected $rule =   [
        'food_name'  => 'require|max:20',
        'food_id'    => 'require',
        'food_content' => 'require',
        'food_img' => 'require',
        'food_category_id' => 'require',
        'food_price' => 'require',
        'food_pack_price' => 'require',
        'food_label' => 'require',
        'food_type' => 'require',
        'food_status' => 'require',
    ];

    protected $message  =   [
        'food_id.require' => '健康美食ID不能为空',
        'food_name.require' => '健康美食名称不能为空',
        'food_content.require'=> '健康美食详情不能为空',
        'food_img.require'   => '健康美食图片不能为空',
        'food_name.max'  => '健康美食名称不能超过20字',
        'food_category_id.require' => '健康美食分类不能为空',
        'food_price.require' => '健康美食价格不能为空',
        'food_pack_price.require' => '打包价格不能为空',
        'food_label.require' => '健康美食标签不能为空',
        'food_type.require' => '健康美食类型不能为空',
        'food_status.require' => '健康美食状态不能为空',
    ];

    //场景
    protected $scene = [
        'create'   => ['food_name','food_img','food_price','food_category_id','food_pack_price','food_label','food_content','food_type','food_status'],
        'update'   => ['food_id','food_name','food_img','food_price','food_category_id','food_pack_price','food_label','food_content','food_type','food_status'],
        'info'     => ['food_id']
    ];
}
