<?php

namespace App\Http\Resources;

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

class EInvoiceInfoResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'street_one' => $this->street_one,
            'street_two' => $this->street_two,
            'district' => $this->district,
            'state' => $this->state,
            'post_code' => (string) $this->postcode,
            'country' => $this->country,
            'billing' => (int) $this->billing,
            'msic_code' => (string) $this->msic_code,
            'tin' => (string) $this->tin,
            'e_invoice' => (int) $this->e_invoice,
            'e_invoice_requested_date' => $this->e_invoice_requested_at ? Carbon::parse($this->e_invoice_requested_at)->format('d-m-Y') : null,
        ];
    }
}
