Files
bogazici-api/app/Http/Resources/MenuResource.php
2026-03-27 10:41:54 +03:00

34 lines
885 B
PHP

<?php
namespace App\Http\Resources;
use App\Models\Menu;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin Menu
*/
class MenuResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'label' => $this->label,
'url' => $this->url,
'location' => $this->location?->value,
'type' => $this->type?->value,
'parent_id' => $this->parent_id,
'order_index' => $this->order_index,
'is_active' => $this->is_active,
'children' => self::collection($this->whenLoaded('children')),
'created_at' => $this->created_at?->toISOString(),
'updated_at' => $this->updated_at?->toISOString(),
];
}
}