<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class PartyUpdateRequest 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()
    {
        $reture = [
            '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',
        ];
        return $reture;
    }
}
