<?php

namespace Modules\PaymentLog\Resources\Api;

use Illuminate\Http\Resources\Json\JsonResource;
use Modules\Canteen\Resources\Api\CanteenResource;
use Modules\Order\Resources\Api\OrderResource;
use Modules\Subscription\Resources\Api\SubscriptionResource;

class PaymentLogResource extends JsonResource
{

    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => (int) $this->id,
            'status' => (int) $this->status,
            'price' => (double) $this->price,
            'points' => (double) $this->points,
            'description' => $this->description,
            'canteen' => new CanteenResource($this->canteen),
            'order' => new OrderResource($this->order),
            'subscription' => new SubscriptionResource($this->subscription),
            'date' => $this->created_at
        ];
    }

}
