<?php

namespace Realestate\Neighbourhood\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class NeighbourhoodResource extends JsonResource
{

    public function itemLink()
    {
        return guard_url('neighbourhood/neighbourhood') . '/' . $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,
            'title' => $this->title,
            'content' => $this->content,
            'description' => $this->description,
            'latitude' => $this->latitude,
            'longitude' => $this->longitude,
            'total_population' => $this->total_population,
            'median_age' => $this->median_age,
            'population_density' => $this->population_density,
            'population_description' => $this->population_description,
            'average_individual_iincome' => $this->average_individual_iincome,
            'household_description' => $this->household_description,
            'total_households' => $this->total_households,
            'average_household_size' => $this->average_household_size,
            'average_individual_income' => $this->average_individual_income,
            'household_with_children' => $this->household_with_children,
            'married' => $this->married,
            'single' => $this->single,
            'divorced' => $this->divorced,
            'separated' => $this->separated,
            'school_data' => $this->school_data,
            'men_vs_women' => $this->men_vs_women,
            'around_description' => $this->around_description,
            'walkable' => $this->walkable,
            'bikeable' => $this->bikeable,
            'transit' => $this->transit,
            'points_of_interest' => $this->points_of_interest,
            'images' => $this->images,
            'status' => $this->status,
            'user_id' => $this->user_id,
            'slug' => $this->slug,
            'country_id' => $this->country_id,
            'state_id' => $this->state_id,
            'city_id' => $this->city_id,
            '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;
    }
}