<?php

namespace App\Http\Resources;

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

class DashboardResource extends JsonResource
{
    /** @return array<string, mixed> */
    public function toArray(Request $request): array
    {
        $data = $this->resource;

        return [
            'meal_suggestions' => isset($data['meal_suggestions'])
                ? RecipeResource::collection($data['meal_suggestions'])
                : [],
            'outfit_suggestions' => isset($data['outfit_suggestions'])
                ? OutfitResource::collection($data['outfit_suggestions'])
                : [],
            'stats' => $data['stats'] ?? [],
            'expiring_items' => isset($data['expiring_items'])
                ? RefrigeratorItemResource::collection($data['expiring_items'])
                : [],
        ];
    }
}
