<?php

namespace Modules\Admin\Services;

use Illuminate\Pagination\LengthAwarePaginator;
use Modules\Admin\Repositories\Interfaces\OrderRepositoryInterface;

class OrderService
{
    public function __construct(
        private OrderRepositoryInterface $orderRepository
    ) {}

    public function getAll(int $perPage = 10, array $filters = []): LengthAwarePaginator
    {
        return $this->orderRepository->paginate($perPage, $filters);
    }

    public function findById(int $id): ?\Modules\Payment\Models\Order
    {
        return $this->orderRepository->find($id);
    }

    public function update(int $id, array $data): \Modules\Payment\Models\Order
    {
        return $this->orderRepository->update($id, $data);
    }

    public function delete(int $id): bool
    {
        return $this->orderRepository->delete($id);
    }

    public function getStatusCounts(): array
    {
        return $this->orderRepository->getStatusCounts();
    }

    public function getRecentOrders(int $limit = 5): \Illuminate\Database\Eloquent\Collection
    {
        return $this->orderRepository->recentOrders($limit);
    }
}
