<?php

namespace Lucent\Query\BuilderConverter;

use Illuminate\Database\Query\Builder;
use Lucent\Query\Filter\Argument;

readonly class NotExists implements IBuilderConverter
{

    public function __construct(private Argument $argument)
    {
    }

    public function toAndQueryBuilder(Builder $builder): Builder
    {
        return $builder->where(fn($b) => $b->where($this->argument->field, "")->orWhereNull($this->argument->field));
    }

    public function toOrQueryBuilder(Builder $builder): Builder
    {
        return $builder->orWhere(fn($b) => $b->where($this->argument->field, "")->orWhereNull($this->argument->field));
    }

}