<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class AppCreateRequest 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_app,phone,'.$this->get('id').',id',
            'appname'  => 'required|min:2|max:14|unique:ag_app,appname,'.$this->get('id').',id',
        ];
    }
}
