<?php

namespace App\Api\Resources\Area;

use Illuminate\Http\Resources\Json\JsonResource;
use SimpleSoftwareIO\QrCode\Facades\QrCode;
use DNS1D;


class AreaCodeVerifyResource extends JsonResource
{

    public function toArray($request): array
    {
        return [
            'area_code_id' => $this->id,
            'code'         => $this->code,
//            'code_img'     => 'data:image/jpg;base64,'.base64_encode(QrCode::format('png')
//                    ->errorCorrection("L")
//                    ->size(300)
//                    ->margin(0)
//                    ->generate($this->code)),
            'barcode'      => 'data:image/png;base64,'.DNS1D::getBarcodePNG($this->code, 'C128', 2, 50),
            'area'         => new AreaFullResource($this->area),
        ];
    }

}
