<?php

namespace Modules\Admin\Services;

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

class CategoryService
{
    public function __construct(
        private CategoryRepositoryInterface $categoryRepository
    ) {}

    public function getAll(int $perPage = 10): LengthAwarePaginator
    {
        return $this->categoryRepository->paginate($perPage);
    }

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

    public function create(array $data): \Modules\Category\Models\Category
    {
        return $this->categoryRepository->create($data);
    }

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

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