<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;
use App\CategoryDescription;
use App\PageDescription;
use App\Models;
use App\Http\Resources\CountryResource;
use App\Http\Resources\AttributeResource;

class CobonResource 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,
            'qr_image'=>asset('').$this->qr_image,
            'code'=> $this->code,
            'count'=> $this->count,
            'daily'=> $this->daily,
            'discount_type'=> $this->discount_type == '1'? 'value':'percentage',
            'discount_amount'=> $this->discount_amount,
            'start_date'=> $this->start_date,
            'end_date'=> $this->end_date,
            'type'=> $this->type,
            'description'=> str_replace($vowels, ' ', strip_tags($this->descriptions(currentLanguage()->id)['description'])),
            
            
            'store'=>new StoreResource($this->whenLoaded('store')),
            
            
            
            
            
      ];
      
    
      return $data;
    }
}
