<?php

namespace Modules\Inventory\Services;

use Modules\Core\Enums\SearchTypeEnum;
use Modules\Inventory\Repositories\ProductRepository;

class ProductSearchService
{
    public function __construct(
        protected ProductRepository $productRepository
    ) {}

    public function search(SearchTypeEnum $type, ?string $search)
    {
        return $this->productRepository
            ->search(
                type: $type,
                search: $search,
                columns: [
                    'id',
                    'name',
                    'sku',
                    'category_id',
                    'base_unit_id',
                    'product_type',
                    'vat_price_type',
                    'vat_type',
                    'vat_rate',
                    'default_selling_price',
                    'subsidy_type',
                    'subsidy_value',
                    'has_stock',
                    'has_batch',
                    'has_expiry',
                    'has_unit_conversion',
                    'status',
                ]
            );
    }
}
