<?php

namespace App\Http\Resources\Sales;

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

class SalesPropertyResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
                'id' => $this->id,
                'title' => $this->title,
                'code' => $this->code,
                'base_price' => $this->base_price,
                'percentage_initial_fee' => $this->percentage_initial_fee,
                'initial_fee' => $this->initial_fee,
                'status' => $this->status,

                'created_at' => $this->created_at,
                'surface' => $this->surface,
                'property_type' => $this->property_type,

                'property_type_id'=> $this->property_type_id,
                'pivot_price'=> $this->pivot->price,
                'pivot_price_it'=> $this->pivot->price_it,
                'pivot_price_contrato'=> $this->pivot->price_contrato,
                'isfacade' => $this->departament ? $this->departament->isfacade: false,
                'is_balcony' => $this->departament ? $this->departament->is_balcony: false,
                'surface_balcony' => $this->departament ? $this->departament->surface_balcony: false,

                'floor_departmennt' => $this->departament ? $this->departament->floor: false,
                'floor_park' => $this->parking ? $this->parking->floor: false,
                'cover' => $this->parking ? ($this->parking->covered ? "Cubierto": "No Cubierto") : false,

                'number_bedrooms' => $this->departament ? $this->departament->number_bedrooms: false,
                'project_title' => $this->project->title,
                'is_balcon'=> $this->features,
        ];
    }
}
