<?php

namespace App\Classes\General\Eloquent\Filters;

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

class DoesNotHaveTransactionType implements Filter
{
    /**
     * @param Builder $builder
     * @param $value
     * @return mixed
     */
    public static function apply(Builder $builder, $value)
    {
        return $builder->whereDoesntHave('transactions', function (Builder $query) use($value) {
            $query->where('type', $value);
        })->whereHas('containers', function ($query){
            return $query->whereDate('loading_date', '>=', Carbon::parse('20-09-2022'));
        });
    }
}