<?php

namespace App\Http\Requests;

use App\Support\Backoffice\Sanitizer\Traits\SanitizesInput;
use Illuminate\Foundation\Http\FormRequest;

class AccountRequest extends FormRequest
{
    use SanitizesInput;

    public function authorize()
    {
        return true;
    }

    public function rules()
    {
        return [
            'companyName' => 'required|max:100',
            'numberOfEmployees' => 'required|max:10',
            'address' => 'required|max:255',
            'floor' => 'nullable|max:255',
            'postalCode' => 'required|max:15',
            'location' => 'required|max:100',
            'countryId' => 'required|integer|exists:countries,id',
            'phonePrefix' => 'required|max:10',
            'phone' => 'required|max:20',
            'email' => 'required|email|max:255',
            'taxId' => 'max:20',
            'specialisationIds' => 'required|array',
            'specialisationIds.*' => 'required|integer|exists:company_specialisations,id',
        ];
    }

    /**
     * Filters to be applied to the input.
     *
     * @return array
     */
    public function filters(): array
    {
        return [
            'companyName' => "trim|strip_tags|xss_clean",
            'numberOfEmployees' => "trim|strip_tags|xss_clean",
            'address' => "trim|strip_tags|xss_clean",
            'floor' => "trim|strip_tags|xss_clean",
            'postalCode' => "trim|strip_tags|xss_clean",
            'location' => "trim|strip_tags|xss_clean",
            'countryId' => "trim|strip_tags|xss_clean",
            'phonePrefix' => "trim|strip_tags|xss_clean",
            'phone' => "trim|strip_tags|xss_clean",
            'email' => "trim|strip_tags|xss_clean",
            'taxId' => "trim|strip_tags|xss_clean",
        ];
    }
}
