<?php

namespace App\Classes\General\Eloquent\Filters;


use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\TransactionType;
use Illuminate\Database\Eloquent\Builder;

class DoesNotHavePurchaseOrderStatusIn implements Filter
{

    /**
     * @param Builder $builder
     * @param $value
     * @return mixed
     */
    public static function apply(Builder $builder, $value)
    {
        return $builder->whereDoesntHave('transactions', function($transaction)  use($value) {
            return $transaction->where('transactions.type', TransactionType::PURCHASE_ORDER)->whereIn('transactions.status', $value);
        });
    }
}
