<?php


namespace app\admin\validate;


class AdminValidate extends BaseValidate
{

     /**
      * 设置校验规则
      * @var string[]
      */
    protected $rule = [
        'id' => 'require',
        'username' => 'require|min:1',
        'nickname' => 'require|min:1',
        'is_kefu'  => 'require|in:0,1',
        'password' => 'min:6',
        'phone' => 'length:0,20',
        'email' => 'email',
        'sex' => 'require|in:0,1,2',
        'role_id' => 'integer',
        'department_id' => 'integer',
        'remark' => 'length:0,100',
        'old_password' => 'require|length:6,20',
        'password_confirmation' => 'require|length:6,20|confirm:password',
    ];

    /**
     * 参数描述
     * @var string[]
     */
    protected $field = [
        'id' => 'id',
        'username' => '账号',
        'nickname' => '昵称',
        'is_kefu'  => '是否是客服',
        'password' => '密码',
        'phone' => '手机号',
        'email' => '邮箱',
        'sex' => '性别',
        'role_id' => '角色ID',
        'department_id' => '部门ID',
        'remark' => '备注',
        'old_password' => '旧密码',
        'password' => '新密码',
        'password_confirmation' => '确认密码',
    ];


    /**
     * @notes 添加场景
     */
    public function sceneAdd()
    {
        return $this->only(['username', 'nickname', 'is_kefu', 'password', 'phone', 'email', 'sex', 'role_id', 'department_id', 'remark']);
    }


    /**
     * @notes 编辑场景
     */
    public function sceneEdit()
    {
        return $this->only(['id','username', 'nickname', 'is_kefu', 'password', 'phone', 'email', 'sex', 'role_id', 'department_id', 'remark']);
    }

    public function sceneDel()
    {
        return $this->only(['id']);
    }

    public function scenePassword()
    {
        return $this->only(['old_password','password','password_confirmation']);
    }

    public function sceneLogin()
    {
        return $this->only(['username','password']);
    }

}