<?php

namespace App\Http\Requests\Member;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'hub_id'            => ['required', 'integer', 'exists:hubs,id'],
            'title'             => ['required', 'string', 'min:10', 'max:120'],
            'description'       => ['required', 'string', 'min:30', 'max:1000'],
            'required_skills'   => ['nullable', 'array', 'max:10'],
            'required_skills.*' => ['string', 'max:80'],
            'preferred_sector'  => ['nullable', 'string', 'max:80'],
            'duration_estimate' => ['nullable', 'string', 'max:50'],
            'timeline'          => ['nullable', 'string', 'max:100'],
            'budget_min_egp'    => ['nullable', 'integer', 'min:0', 'max:9999999'],
            'budget_max_egp'    => ['nullable', 'integer', 'min:0', 'max:9999999',
                                    'gte:budget_min_egp'],
            'budget_is_visible' => ['boolean'],
        ];
    }

    public function messages(): array
    {
        return [
            'hub_id.required'       => __('freelance.validation.hub_required'),
            'title.required'        => __('freelance.validation.brief_title_required'),
            'title.min'             => __('freelance.validation.brief_title_min'),
            'description.required'  => __('freelance.validation.brief_description_required'),
            'description.min'       => __('freelance.validation.brief_description_min'),
            'budget_max_egp.gte'    => __('freelance.validation.rate_max_gte'),
        ];
    }
}
