<?php

namespace App\Master\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class ApiTokenView extends JsonResource
{
    public static $wrap = '';

    /**
     * Transform the resource into an array.
     *
     * @return array<string, mixed>
     */
    #[\Override]
    public function toArray(Request $request): array
    {
        return [
            'token' => $this->resource->token,
            'expires_in' => $this->resource->expires_at->diffInSeconds(now(), true)
        ];
    }
}
