<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class MenuResource extends JsonResource
{
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'parent_id' => $this->parent_id,
            'name' => $this->name,
            'icon' => $this->icon,
            'path' => $this->path,
            'component' => $this->component,
            'permission_code' => $this->permission_code,
            'type' => $this->type,
            'visible' => $this->visible,
            'sort' => $this->sort,
            'status' => $this->status,
            'create_time' => $this->create_time,
            'update_time' => $this->update_time,
            'children' => $this->when(isset($this->children), $this->children),
        ];
    }
}
