<?php

namespace Realestate\Property\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class PropertyResource extends JsonResource
{

    public function itemLink()
    {
        return guard_url('property/property') . '/' . $this->getRouteKey();
    }

    public function title()
    {
        if ($this->title != '') {
            return $this->title;
        }

        if ($this->name != '') {
            return $this->name;
        }

        return 'None';
    }

    public function toArray($request)
    {
        return [
            'id' => $this->getRouteKey(),
            'title' => $this->title(),
            'slug' => $this->slug,
            'type' => $this->type,
            'building_type' => $this->building_type,
            'builder_id' => $this->builder_id,
            'category' => $this->category,
            'number' => $this->number,
            'property_code' => $this->property_code,
            'title' => $this->title,
            'area' => $this->area,
            'community' => $this->community,
            'central_vac' => $this->central_vac,
            'unit_exposure' => $this->unit_exposure,
            'water_supply' => $this->water_supply,
            'tax_year' => $this->tax_year,
            'tax_legal_description' => $this->tax_legal_description,
            'central_ac_included' => $this->central_ac_included,
            'utilities' => $this->utilities,
            'fronting_on' => $this->fronting_on,
            'lot_depth' => $this->lot_depth,
            'frontage' => $this->frontage,
            'lot_size' => $this->lot_size,
            'acre' => $this->acre,
            'sewer' => $this->sewer,
            'zoning' => $this->zoning,
            'home_style' => $this->home_style,
            'price' => $this->price,
            'bedrooms' => $this->bedrooms,
            'bathrooms' => $this->bathrooms,
            'bed_plus' => $this->bed_plus,
            'rooms' => $this->rooms,
            'kitchen' => $this->kitchen,
            'fire_place' => $this->fire_place,
            'family_room' => $this->family_room,
            'furnished' => $this->furnished,
            'basement' => $this->basement,
            'heating' => $this->heating,
            'fuel_heating' => $this->fuel_heating,
            'exterior' => $this->exterior,
            'private_entrance' => $this->private_entrance,
            'drive_way' => $this->drive_way,
            'garage_type' => $this->garage_type,
            'garage_size' => $this->garage_size,
            'parking_space' => $this->parking_space,
            'parking_fee_included' => $this->parking_fee_included,
            'features' => $this->features,
            'floor_plans' => $this->floor_plans,
            'website' => $this->website,
            'property_size' => $this->property_size,
            'available_from' => $this->available_from,
            'featured' => $this->featured,
            'description' => $this->description,
            'user_id' => $this->user_id,
            'user_type' => $this->user_type,
            'images' => $this->images,
            'floor_no' => $this->floor_no,
            'country_id' => $this->country_id,
            'state_id' => $this->state_id,
            'city_id' => $this->city_id,
            'location' => $this->location,
            'booking_status' => $this->booking_status,
            'views' => $this->views,
            'unit_area' => $this->unit_area,
            'balcony_area' => $this->balcony_area,
            'source' => $this->source,
            'board' => $this->board,
            'status' => $this->status,
            'slug' => $this->slug,
            'marking' => $this->marking,
            'created_at' => !is_null($this->created_at) ? $this->created_at->format('Y-m-d H:i:s') : null,
            'updated_at' => !is_null($this->updated_at) ? $this->updated_at->format('Y-m-d H:i:s') : null,
            'meta' => [
                'exists' => $this->exists(),
                'link' => $this->itemLink(),
                'upload_url' => $this->getUploadURL(''),
                'workflow' => $this->workflows(),
                'actions' => $this->actions(),
            ],
        ];
    }

    /**
     * Get additional data that should be returned with the resource array.
     *
     * @param     \Illuminate\Http\Request  $request
     * @return array
     */
    public function with($request)
    {
        return [
            'meta' => [
                'exists' => $this->exists(),
                'link' => $this->itemLink(),
                'upload_url' => $this->getUploadURL(''),
                'workflow' => $this->workflows(),
                'actions' => $this->actions(),
            ],
        ];
    }

    /**
     * Get the workflows for the resource.
     *
     * @return array
     */
    private function workflows()
    {
        $arr = [];
                return $arr;

    }
    
    /**
     * Get the actions for the resource.
     *
     * @return array
     */
    private function actions()
    {

        $arr = [];
        
        return $arr;
    }
}