<?php

namespace App\Http\Requests\Member;

use Illuminate\Foundation\Http\FormRequest;

class StoreFreelanceProfileRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'hub_id'           => ['required', 'integer', 'exists:hubs,id'],
            'headline'         => ['required', 'string', 'min:10', 'max:120'],
            'description'      => ['required', 'string', 'min:30', 'max:1000'],
            'services'         => ['required', 'array', 'min:1', 'max:10'],
            'services.*'       => ['required', 'string', 'max:80'],
            'sector_expertise' => ['nullable', 'array', 'max:5'],
            'sector_expertise.*' => ['string', 'max:80'],
            'experience_level' => ['required', 'string', 'in:student,fresh,junior,mid,senior'],
            'availability'     => ['required', 'string', 'in:weekends,evenings,full,unavailable'],
            'rate_min_egp'     => ['nullable', 'integer', 'min:0', 'max:9999999'],
            'rate_max_egp'     => ['nullable', 'integer', 'min:0', 'max:9999999',
                                   'gte:rate_min_egp'],
            'rate_is_visible'  => ['boolean'],
            'linkedin_url'     => ['nullable', 'url', 'max:255',
                                   'regex:/^https:\/\/(www\.)?linkedin\.com\/.+/'],
        ];
    }

    public function messages(): array
    {
        return [
            'hub_id.required'        => __('freelance.validation.hub_required'),
            'headline.required'      => __('freelance.validation.headline_required'),
            'headline.min'           => __('freelance.validation.headline_min'),
            'description.required'   => __('freelance.validation.description_required'),
            'description.min'        => __('freelance.validation.description_min'),
            'services.required'      => __('freelance.validation.services_required'),
            'services.min'           => __('freelance.validation.services_min'),
            'experience_level.in'    => __('freelance.validation.experience_invalid'),
            'availability.in'        => __('freelance.validation.availability_invalid'),
            'rate_max_egp.gte'       => __('freelance.validation.rate_max_gte'),
            'linkedin_url.url'       => __('freelance.validation.linkedin_url'),
            'linkedin_url.regex'     => __('freelance.validation.linkedin_url'),
        ];
    }
}
