<?php

namespace App\Modules\Production\Services;

use App\Modules\Production\Contracts\ProductionServiceInterface;
use App\Modules\Production\Models\ProductionOrder;
use App\Modules\Production\Models\ProductionOrderItem;

class ProductionService implements ProductionServiceInterface
{
    public function getPendingProductionCount(): int
    {
        return ProductionOrder::where('status', 'pending')->count();
    }

    public function getProductionOrdersByOutputBatch(string $batchNumber): \Illuminate\Support\Collection
    {
        return ProductionOrder::with(['items.inventory.product', 'items.inventory'])
            ->where('output_batch_number', $batchNumber)
            ->get();
    }

    public function getProductionOrderItemsByInventoryId(int $inventoryId, array $with = []): \Illuminate\Support\Collection
    {
        return ProductionOrderItem::with($with)
            ->where('inventory_id', $inventoryId)
            ->get();
    }
}
