<?php
namespace App\Http\Requests\Admin;

use Illuminate\Foundation\Http\FormRequest;

class StorePlanningsRequest 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 [
            'name' => 'max:192',
            'image' => 'mimes:png,jpg,jpeg,gif|required',
            'cost_per_square_meter' => 'nullable|regex:/^[0-9]{0,9}([.]{1}[0-9]{1,2})?$/',
            'space' => 'regex:/^[0-9]{0,9}([.]{1}[0-9]{1,2})?+$/i|required',
            'count_of_floor' => 'numeric|min:0|max:200|nullable',
            'total_cost' => 'nullable|regex:/^[0-9]{0,9}([.]{1}[0-9]{1,2})?+$/i',
            'room_id' => 'nullable',
            'floor_id.*' => 'exists:floors,id',
            'section_id' => 'required',
            'amount_of_apartment' => 'numeric|min:0|max:999|nullable'
        ];
    }

    public function messages()
    {
        return [
            'cost_per_square_meter.regex' =>
                'Поле має містити тільки цифри та 2 знаки після крапки. Приклад: 12.00',
            'total_cost.regex' =>
                'Поле має містити тільки цифри та 2 знаки після крапки. Приклад: 12.00',
            'space.regex' =>
                'Поле має містити тільки цифри та 2 знаки після крапки. Приклад: 12.00',
        ];
    }
}
