<?php

namespace Modules\Section\Services;

use Modules\Section\Repositories\Interfaces\SectionRepositoryInterface;

class SectionService
{
    public function __construct(
        private SectionRepositoryInterface $sectionRepository
    ) {}

    public function getAll(): \Illuminate\Database\Eloquent\Collection
    {
        return $this->sectionRepository->getActive();
    }

    public function getById(int $id): ?\Modules\Section\Models\Section
    {
        return $this->sectionRepository->find($id);
    }

    public function getByKey(string $key): ?\Modules\Section\Models\Section
    {
        return $this->sectionRepository->findByKey($key);
    }

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

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

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