<?php
namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class RegionResource extends JsonResource
{
    public function toArray($request): array
    {
        return [
            'id'        => $this->id,
            'name'      => $this->name,
            'districts' => DistrictResource::collection($this->whenLoaded('districts')),
        ];
    }
}
