<?php

namespace App\Http\Resources;

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

class AuthResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'access_token'  => data_get($this, 'access_token'),
            'refresh_token' => data_get($this, 'refresh_token'),
            'token_type'    => 'Bearer',
            'expires_in'    => 900,
            'user'          => new UserResource(data_get($this, 'user')),
        ];
    }

    public static function collection($resource): AnonymousResourceCollection
    {
        return parent::collection($resource);
    }
}
