<?php

namespace App\Classes\General\Eloquent\Filters;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;

class IsPublished implements Filter
{

    /**
     * @param Builder $builder
     * @param $value
     * @return Builder|mixed
     */
    public static function apply(Builder $builder, $value)
    {
        return $builder->whereDate('starting_on', '<=', Carbon::now())
            ->whereDate('ending_on', '>=', Carbon::now());
    }
}
