<?php
namespace app\validate;


use think\Validate;

class BusinessValidate extends Validate
{
    protected $rule = [
        'type'  => 'require|gt:0',
        'business_name|商家名称' => 'require|max:150',
        'business_subtitle|商家简称' => 'require|max:150',
        'business_license|营业执照'  => 'require|max:250',
        'contact_name|联系人'      => 'require|max:20',
        'contact_phone|联系电话'    => 'require|max:20',
        'lat'   => 'require|between:-90,90',
        'lng'   => 'require|between:-180,180',

        'province|所属省份'  => 'require',
        'city|所属城市'  => 'require',
        'county|所属区县'  => 'require',
        'business_address|商家地址'  => 'require|max:250',

        'characteristic|商家特色'   => 'max:250',
        'background|商家背景图'       => 'require|max:250',
        'business_circle_id|所属商圈'        => 'egt:0',

    ];

    protected $message = [
        'type.require'  => '请选择商家分类！',
        'type.gt'       => '请选择商家分类！',

        'lat.require'   => '地址定位信息错误，请重新定位！',
        'lat.between'   => '地址定位信息错误，请重新定位！',
        'lng.require'   => '地址定位信息错误，请重新定位！',
        'lng.between'   => '地址定位信息错误，请重新定位！',

        'business_circle_id.egt'       => '请选择所属商圈！',
    ];

    protected $scene = [
        // 认证商家
        'apiRegister'   => ['type', 'business_name', 'business_subtitle', 'business_license', 'contact_name', 'contact_phone',
            'lat', 'lng', 'province', 'city', 'county', 'business_address', 'business_circle_id'],
        // 商家编辑可编辑资料（基本信息修改需要审核通过后才能变更）
        'apiEdit'       => ['lat', 'lng', 'province', 'city', 'county', 'business_address', 'characteristic', 'background', 'business_circle_id'],
    ];
}