<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class PropertyRequest 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 [
			'customer_id' => 'required|numeric',
			'address_type' => 'required',
			'location.address' => 'required|min:3',
			'location.city' => 'required',
			'location.state' => 'required',
			'location.zip_code' => 'required',
			'location.lat' => 'required',
			'location.lng' => 'required',
			'general_informations.has_dog' => 'required',
			'bodies_of_water' => 'required'
		];
    }
	
	public function response(array $errors)
	{
		return response()->json([
				'title' => 'Property',
				'message' => 'Check the required fields and try again.',
				'errors' => $errors
			], 422);
	}
	
}
