<?php

namespace App\Http\Resources\V2;


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

class DocumentV2Resource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'reference' => $this->reference,
            'status' => (int) $this->status,
            'document_type' => $this->document_type,
            'files' => FileV2Resource::collection($this->files),
            'created_at' => Carbon::parse($this->created_at)->format('d-m-Y h:i:s A')
        ];
    }
}
