<?php

declare(strict_types=1);

namespace App\Http\Resources;

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

class MediaCategoryResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'parent_id' => $this->parent_id,
            'name' => $this->name,
            'type' => $this->type,
            'sort_order' => $this->sort_order,
            'children' => MediaCategoryResource::collection($this->whenLoaded('children')),
        ];
    }
}
