<?php
// +----------------------------------------------------------------------
// | saiadmin [ saiadmin快速开发框架 ]
// +----------------------------------------------------------------------
// | Author: your name
// +----------------------------------------------------------------------
namespace app\dice\validate\player;

use app\dice\model\player\DicePlayer;
use plugin\saiadmin\basic\BaseValidate;

/**
 * 大富翁-玩家验证器
 */
class DicePlayerValidate extends BaseValidate
{
    /**
     * 定义验证规则
     */
    protected $rule =   [
        'username' => 'require|unique:' . DicePlayer::class . ',username^dept_id',
        'name' => 'require',
        'phone' => 'require',
        'password' => 'require',
        'status' => 'require',
        'coin' => 'require',
    ];

    /**
     * 定义错误信息
     */
    protected $message  =   [
        'username' => '用户名必须填写',
        'username.unique' => 'PLAYER_USERNAME_DEPT_UNIQUE',
        'name' => '昵称必须填写',
        'phone' => '手机号必须填写',
        'password' => '密码必须填写',
        'status' => '状态必须填写',
        'coin' => '平台币必须填写',
    ];

    /**
     * 定义场景（update 时密码可选，不填则不修改）
     */
    protected $scene = [
        'save' => [
            'username',
            'name',
            'phone',
            'password',
            'status',
            'coin',
        ],
        'update' => [
            'username',
            'name',
            'phone',
            'status',
            'coin',
        ],
    ];

}
