<?php

namespace Modules\WeeklySpecial\Repositories;

use Illuminate\Database\Eloquent\Collection;
use Modules\WeeklySpecial\Models\WeeklySpecial;
use Modules\WeeklySpecial\Repositories\Interfaces\WeeklySpecialRepositoryInterface;

class WeeklySpecialRepository implements WeeklySpecialRepositoryInterface
{
    public function __construct(
        private WeeklySpecial $model
    ) {}

    public function getActive(): Collection
    {
        return $this->model->where('is_active', true)
            ->where('starts_at', '<=', now())
            ->where('ends_at', '>=', now())
            ->get();
    }

    public function findBySlug(string $slug): ?WeeklySpecial
    {
        return $this->model->where('slug', $slug)->first();
    }
}
