<?php

namespace App\Api\Resources\Area;

use App\Api\Resources\BaseCollection;
use App\Api\Resources\User\UserBaseResource;

class AreaCodeCollection extends BaseCollection
{

    public function toArray($request): array
    {
        return [
            'data' => $this->collection->map(function ($info) {
                return [
                    'area_code' => $info->id,
                    'user'      => $info->user ? new UserBaseResource($info->user) : "",
                    'code'      => $info->code,
                    'status'    => [
                        'status' => $info->status,
                        'text'   => $info->status_text,
                    ],
                ];
            }),
            'page' => $this->page(),
        ];
    }

}