<?php

namespace App\Classes\General\Eloquent\Filters;


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

class CreatedAfterOrEqual implements Filter
{

    /**
     * @param Builder $builder
     * @param $value
     * @return mixed
     */
    public static function apply(Builder $builder, $value)
    {
        $table = $builder->getModel()->getTable();
        $startDate = Carbon::createFromFormat('d-m-Y', $value)->startOfDay();
        return $builder->where("{$table}.created_at", '>=', $startDate);
    }
}