<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class PartyCreateRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'balance' => 'required|regex:/^[0-9]{1,8}(.[0-9]{1,2})?$/|',
            'phone' => 'required|numeric|regex:/^1[34578][0-9]{9}$/|unique:ag_party,phone,'.$this->get('id').',id',
            'key' => 'required|unique:ag_party,key,'.$this->get('id').',id',
            'name'  => 'required|min:2|max:14|unique:ag_party,name,'.$this->get('id').',id',
            //'balance' => 'required|regex:/^[0-9]{1,8}(.[0-9]{1,2})?$/,'.$this->get('id').',id',
            //'phone'   => 'required|numeric|regex:/^1[3456789][0-9]{9}$/|unique:users',
            //'username'  => 'required|min:4|max:14|unique:users',
        ];
    }
}
