Files
lucent-laravel/src/Query/BuilderConverter/NotEquals.php
T
2024-08-24 17:22:40 +03:00

29 lines
674 B
PHP

<?php
namespace Lucent\Query\BuilderConverter;
use Illuminate\Database\Query\Builder;
use Lucent\Query\Filter\Argument;
readonly class NotEquals implements IBuilderConverter
{
public function __construct(private Argument $argument)
{
}
public function toAndQueryBuilder(Builder $builder): Builder
{
return $builder->whereNot($this->argument->field, $this->formatValue());
}
public function toOrQueryBuilder(Builder $builder): Builder
{
return $builder->orWhereNot($this->argument->field, $this->formatValue());
}
private function formatValue(): string
{
return trim($this->argument->value);
}
}