<?php

namespace App\Http\Resources\Reports;

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

class TopProductResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'product_id' => $this->product_id,
            'name' => $this->product_name, // Aggregated or joined
            'sku' => $this->sku,
            'total_quantity' => (float) $this->total_quantity,
            'total_revenue' => (float) $this->total_revenue,
            'total_profit' => (float) ($this->total_revenue - $this->total_cost),
        ];
    }
}
