<?php

declare(strict_types=1);

namespace App\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

/**
 * @mixin \App\Models\PropertyProposal
 */
class PropertyProposalResource extends JsonResource
{
    /**
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'request_id' => $this->request_id,
            'proposed_by_user_id' => $this->proposed_by_user_id,
            'title' => $this->title,
            'property_type' => $this->property_type instanceof \BackedEnum ? $this->property_type->value : $this->property_type,
            'city_id' => $this->city_id,
            'zone_id' => $this->zone_id,
            'price' => $this->price,
            'surface' => $this->surface,
            'rooms' => $this->rooms,
            'bedrooms' => $this->bedrooms,
            'description' => $this->description,
            'commission_requested' => $this->commission_requested,
            'status' => $this->status instanceof \BackedEnum ? $this->status->value : $this->status,
            'images' => $this->resource->publicImageUrls(),
            'created_at' => $this->created_at?->toIso8601String(),
            'updated_at' => $this->updated_at?->toIso8601String(),
        ];
    }
}
