<?php

namespace App\Repositories\Eloquent;

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

class ScoopYieldRepository extends BaseRepository
{
    protected function resolveModel(): Model
    {
        return new ScoopYield();
    }

    public function getActive()
    {
        return $this->model->active()->with(['ingredient', 'optionSetItem'])->get();
    }

    public function getForIngredient(int $ingredientId)
    {
        return $this->model->forIngredient($ingredientId)
            ->with('optionSetItem')
            ->get();
    }

    public function findByIngredientAndSize(int $ingredientId, ?int $optionSetItemId): ?ScoopYield
    {
        return $this->model->where('ingredient_id', $ingredientId)
            ->where('option_set_item_id', $optionSetItemId)
            ->active()
            ->first();
    }
}
