MemberValidate.php 1.5 KB
<?php
/**
 * Created by PhpStorm.
 * User: 29925
 * Date: 2018/8/9
 * Time: 11:02
 */

namespace app\member\validate;

use think\Validate;

class MemberValidate extends Validate
{

    protected $rule = [
        'mobile'       => 'require|unique:member,mobile',
        'user_login'   => 'require|unique:member,user_login',
        'baby_name'    => 'require',
        'baby_birth'   => 'require',
        'parent_name'  => 'require',
        'parent_status'=> 'require',
        'is_member'    => 'require|in:0,1',
        'baby_age'     => 'require|number',
    ];

    protected $message = [
        'mobile.require'        => '手机号码不能为空',
        'mobile.unique'         => '手机号码已存在',
        'user_login.require'    => '手机号码不能为空',
        'user_login.unique'     => '手机号码已存在',
        'baby_name.require'     => '宝宝姓名不能为空',
        'baby_birth.require'    => '宝宝生日不能为空',
        'parent_name.require'   => '家长姓名不能为空',
        'parent_status.require' => '家长身份不能为空',
        'is_member.in'          => '巧虎身份选择错误',
        'baby_age.require'      => '宝宝年龄不能为空',
        'baby_age.number'       => '宝宝年龄必须为数字',
    ];

    protected $scene = [
        'add'  => ['mobile', 'user_login', 'baby_name', 'baby_birth', 'parent_name', 'parent_status', 'is_member'],
        'edit' => ['baby_age'],
        'admin_edit' => ['baby_name', 'baby_birth', 'parent_name', 'parent_status', 'is_member'],
    ];
}