class Unique

Properties

protected string $table

The table to run the query against.

protected string $column

The column to check for uniqueness on.

protected mixed $ignore

The ID that should be ignored.

protected string $idColumn

The name of the ID column.

protected array $wheres

There extra where clauses for the query.

protected Closure|null $using

The custom query callback.

Methods

void
__construct(string $table, string $column = 'NULL')

Create a new unique rule instance.

$this
where(string $column, string $value = null)

Set a "where" constraint on the query.

$this
whereNot(string $column, string $value)

Set a "where not" constraint on the query.

$this
whereNull(string $column)

Set a "where null" constraint on the query.

$this
whereNotNull(string $column)

Set a "where not null" constraint on the query.

$this
ignore(mixed $id, string $idColumn = 'id')

Ignore the given ID during the unique check.

$this
using(Closure $callback)

Register a custom query callback.

string
formatWheres()

Format the where clauses.

array
queryCallbacks()

Get the custom query callbacks for the rule.

string
__toString()

Convert the rule to a validation string.

Details

at line 58
void __construct(string $table, string $column = 'NULL')

Create a new unique rule instance.

Parameters

string $table
string $column

Return Value

void

at line 71
$this where(string $column, string $value = null)

Set a "where" constraint on the query.

Parameters

string $column
string $value

Return Value

$this

at line 89
$this whereNot(string $column, string $value)

Set a "where not" constraint on the query.

Parameters

string $column
string $value

Return Value

$this

at line 100
$this whereNull(string $column)

Set a "where null" constraint on the query.

Parameters

string $column

Return Value

$this

at line 111
$this whereNotNull(string $column)

Set a "where not null" constraint on the query.

Parameters

string $column

Return Value

$this

at line 123
$this ignore(mixed $id, string $idColumn = 'id')

Ignore the given ID during the unique check.

Parameters

mixed $id
string $idColumn

Return Value

$this

at line 137
$this using(Closure $callback)

Register a custom query callback.

Parameters

Closure $callback

Return Value

$this

at line 149
protected string formatWheres()

Format the where clauses.

Return Value

string

at line 161
array queryCallbacks()

Get the custom query callbacks for the rule.

Return Value

array

at line 171
string __toString()

Convert the rule to a validation string.

Return Value

string