<?php

namespace Modules\Offer\Models\Resources;

use Illuminate\Http\Resources\Json\JsonResource;
use Modules\Category\Models\Resources\CategoryResource;
use Modules\Store\Models\Resources\StoreResource;

class OfferResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'status'=> $this->status,
            'start_date'=> $this->start_date,
            'end_date'=> $this->end_date,
            'percentage'=> $this->percentage,
            'title'=>$this->currentDescription->title,
            'store'=>new StoreResource($this->whenLoaded('store')),
            'category'=>new CategoryResource($this->whenLoaded('category')),
            'subCategory'=>new CategoryResource($this->whenLoaded('subCategory')),
        ];
    }
}
