<?php

namespace App\Repositories\Eloquent;

use App\Models\OptionSet;
use Illuminate\Database\Eloquent\Model;

class OptionSetRepository extends BaseRepository
{
    protected function resolveModel(): Model
    {
        return new OptionSet();
    }

    public function all(array $columns = ['*']): \Illuminate\Database\Eloquent\Collection
    {
        return $this->model->with('items')->get($columns);
    }

    public function getActive()
    {
        return $this->model->active()->with('items')->get();
    }

    public function getByType(string $type)
    {
        return $this->model->byType($type)->active()->with('items')->get();
    }

    public function getWithActiveItems(int $id): ?OptionSet
    {
        return $this->model->with('activeItems')->find($id);
    }
}
