<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;
use App\CategoryDescription;
use App\CityDescription;
use App\Models;
use App\Http\Resources\AreaResource;
use App\Http\Resources\AttributeResource;

class CompetitionResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
     
    public function toArray($request)
    {
        
       
        $vowels = array("&nbsp;", "&ndash;", "&bull;","\r\n","&ldquo;","&rdquo;");
       
        $data =  [
            'id' => $this->id,
            'image'=>asset('').$this->image,
            'start_date' => $this->start_date,
            'end_date' => $this->end_date,
            'prize_date' => $this->prize_date,
            'subscribed' => subcomp($this->id),
            'name' => $this->descriptions(currentLanguage()->id)['name'],
            'prize' =>  str_replace($vowels, ' ', strip_tags($this->descriptions(currentLanguage()->id)['prize'])),
            'description'=> str_replace($vowels, ' ', strip_tags($this->descriptions(currentLanguage()->id)['description'])),
           
            
            
            'questions'=>QuestionResource::collection($this->whenLoaded('questions')),
            
            
            
      ];
      return $data;
    }
}
