<?php

namespace App\Http\Requests\Member;

use Illuminate\Foundation\Http\FormRequest;

// ══════════════════════════════════════════════════════════════════
//  InPractice — StoreJobListingRequest
//  Location: app/Http/Requests/Member/StoreJobListingRequest.php
//
//  Validates creating a job listing.
//  Any member can post a job — no special role needed.
//  Update uses the same rules with sometimes — see UpdateJobListingRequest.
// ══════════════════════════════════════════════════════════════════

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

    public function rules(): array
    {
        return [
            'hub_id'               => ['required', 'integer', 'exists:hubs,id'],
            'job_title'            => ['required', 'string', 'max:100'],
            'company_name'         => ['required', 'string', 'max:100'],
            'industry'             => ['required', 'string', 'max:100'],
            'location_city'        => ['nullable', 'string', 'max:100'],
            'job_type'             => ['required', 'string', 'in:full_time,part_time,contract,internship'],
            'description'          => ['required', 'string', 'min:50', 'max:3000'],
            'required_skills'      => ['nullable', 'array', 'max:20'],
            'required_skills.*'    => ['required', 'string', 'max:50'],
            'min_experience_years' => ['nullable', 'integer', 'min:0', 'max:30'],
            'salary_range'         => ['nullable', 'string', 'max:100'],
        ];
    }

    public function messages(): array
    {
        return [
            'description.min' => __('cv.validation.description_min'),
            'hub_id.exists'   => __('cv.validation.hub_invalid'),
        ];
    }
}
