<?php

namespace Modules\Rate\Models\Resources;

use Illuminate\Http\Resources\Json\JsonResource;
use Modules\Option\Models\Resources\OptionResource;
use Modules\Order\Models\Resources\OrderProductResource;
use Modules\Order\Models\Resources\OrderResource;
use Modules\Product\Models\Resources\ProductResource;
use Modules\Reason\Models\Resources\ReasonResource;
use Modules\Region\Models\Resources\RegionResource;
use Modules\User\Models\Resources\AddressResource;
use Modules\User\Models\Resources\PaymentCardResource;
use Modules\User\Models\Resources\UserResource;

class RateResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'rate'=>$this->rate,
            'comment'=>$this->comment,
            'date'=>date('Y-m-d g:i a',strtotime($this->created_at)),
            'user'=>new UserResource($this->whenLoaded('user')),
            'product'=>new ProductResource($this->whenLoaded('product')),
        ];
    }
}
