<?php

namespace App\Http\Resources\Backoffice\CompanyProfiles;

use Illuminate\Http\Resources\Json\JsonResource;

class CompanyProfileJobOfferResource extends JsonResource
{
    public function toArray($request)
    {
        return [
            'id'               => $this->id,
            'title'            => $this->title,
            'subtitle'         => $this->subtitle,
            'content'          => $this->content,
            'countryId'        => $this->country_id,
            'activeUntil'      => $this->active_until?->format('Y-m-d'),
            'contactPerson'    => $this->contact_person,
            'contactEmail'     => $this->contact_email,
            'contactByEmail'   => (bool) $this->contact_by_email,
            'contactByLetter'  => (bool) $this->contact_by_letter,
            'contactUrl'       => $this->contact_url,
            'contactName'      => $this->contact_name,
            'contactAddress'   => $this->contact_address,
            'contactPostalCode' => $this->contact_postal_code,
            'contactCity'      => $this->contact_city,
            'status'           => $this->status,
            'specialisationIds' => $this->whenLoaded('specialisations', fn () => $this->specialisations->pluck('id')->values()),
            'createdAt'        => $this->created_at,
            'updatedAt'        => $this->updated_at,
        ];
    }
}
