<?php

namespace App\Http\Resources\Public;

use Illuminate\Http\Request;

/** The full public job page (§162 "Job Detail"). */
class PublicJobDetailResource extends PublicJobResource
{
    public function toArray(Request $request): array
    {
        return array_merge(parent::toArray($request), [
            'responsibilities' => $this->public_responsibilities,
            'qualification' => $this->qualification,
            'skills' => $this->skills,
            'language_requirements' => $this->language_requirements,
            'employment_terms' => $this->employment_terms,

            'working_hours_per_day' => $this->working_hours_per_day,
            'working_days_per_week' => $this->working_days_per_week,
            'weekly_holiday' => $this->weekly_holiday,
            'overtime_details' => $this->overtime_details,
            'probation_months' => $this->probation_months,

            'benefits' => [
                'accommodation' => (bool) $this->accommodation_provided,
                'food' => (bool) $this->food_provided,
                'transport' => (bool) $this->transport_provided,
                'medical' => (bool) $this->medical_provided,
                'insurance' => (bool) $this->insurance_provided,
                'airfare_terms' => $this->airfare_terms,
                'notes' => $this->benefits_notes,
            ],

            'interview_date' => $this->interview_date?->toDateString(),

            // Documents a candidate should expect to provide, resolved from the
            // configured requirements for this demand and country (§17A).
            'required_documents' => $this->when(
                isset($this->publicRequiredDocuments),
                fn () => $this->publicRequiredDocuments,
            ),

            'seo' => [
                'title' => $this->seo_title ?: $this->job_title,
                'description' => $this->seo_description ?: $this->public_summary,
            ],
        ]);
    }
}
