<?php

namespace App\Classes\General\Eloquent\Filters;


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

class WarehouseParcels implements Filter
{

    /**
     * @param Builder $builder
     * @param $value
     * @return mixed
     */
    public static function apply(Builder $builder, $value)
    {
        return $builder->whereHas('packingList', function ($query){
            return $query->where('type', PackingListType::WAREHOUSE_RECEIVE_LIST)->where('status', ApprovalStatus::APPROVED);
        });
    }
}