<?php

namespace App\Http\Requests\CRM;

use Illuminate\Foundation\Http\FormRequest;

class UpdateAddressRequest extends FormRequest
{

    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        // We need separate rules for "residence" and "mailing" arrays, 
        // because the form inputs are now prefixed.
        return [
            'residence.line_1'  => ['sometimes', 'required', 'string', 'max:255'],
            'residence.city_id' => ['sometimes', 'required', 'exists:cities,id'],

            'mailing.line_1'  => ['sometimes', 'required', 'string', 'max:255'],
            'mailing.city_id' => ['sometimes', 'required', 'exists:cities,id'],
        ];
    }

}
