<?php

namespace App\Http\Resources\Admin;

use Illuminate\Http\Resources\Json\JsonResource;
use Carbon\Carbon;
class SubscriptionIndexResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'user' => [
                'id' => $this->user->id,
                'name' => $this->user->name,
                'email' => $this->user->email,
            ],
            'product_id' => $this->product_id,
            'platform' => $this->platform,
            'purchase_token' => $this->purchase_token,
            'expires_at' => Carbon::parse($this->expires_at)->format('Y-m-d H:i:s'),
            'is_active' => $this->is_active,
            'raw_response' => $this->raw_response,

        ];
    }
}
