<?php

namespace App\Http\Resources\Inventory;

use Illuminate\Http\Resources\Json\JsonResource;

class InventoryItemResource extends JsonResource
{
    public function toArray($request): array
    {
        return [
            'id' => (int) ($this['id'] ?? 0),
            'type' => (string) ($this['type'] ?? ''),
            'category_id' => $this['category_id'] ?? null,
            'name' => (string) ($this['name'] ?? ''),
            'description' => $this['description'] ?? null,
            'quantity' => (int) ($this['quantity'] ?? 0),
            'good_qty' => $this['good_qty'] ?? null,
            'needs_repair_qty' => $this['needs_repair_qty'] ?? null,
            'need_replace_qty' => $this['need_replace_qty'] ?? null,
            'cannot_find_qty' => $this['cannot_find_qty'] ?? null,
            'unit' => $this['unit'] ?? null,
            'condition' => $this['condition'] ?? null,
            'isbn' => $this['isbn'] ?? null,
            'edition' => $this['edition'] ?? null,
            'sku' => $this['sku'] ?? null,
            'notes' => $this['notes'] ?? null,
            'semester' => $this['semester'] ?? null,
            'school_year' => $this['school_year'] ?? null,
            'updated_by' => $this['updated_by'] ?? null,
        ];
    }
}
