Unique
class Unique (View source)
Traits
DatabaseRule |
Properties
protected string | $table | The table to run the query against. | from DatabaseRule |
protected string | $column | The column to check on. | from DatabaseRule |
protected array | $wheres | The extra where clauses for the query. | from DatabaseRule |
protected array | $using | The array of custom query callbacks. | from DatabaseRule |
protected mixed | $ignore | The ID that should be ignored. | |
protected string | $idColumn | The name of the ID column. |
Methods
void | __construct(string $table, string $column = 'NULL') Create a new rule instance. | from DatabaseRule |
string | resolveTableName(string $table) Resolves the name of the table from the given string. | from DatabaseRule |
$this | where(Closure|string $column, array|string|int|null $value = null) Set a "where" constraint on the query. | from DatabaseRule |
$this | whereNot(string $column, array|string $value) Set a "where not" constraint on the query. | from DatabaseRule |
$this | whereNull(string $column) Set a "where null" constraint on the query. | from DatabaseRule |
$this | whereNotNull(string $column) Set a "where not null" constraint on the query. | from DatabaseRule |
$this | whereIn(string $column, array $values) Set a "where in" constraint on the query. | from DatabaseRule |
$this | whereNotIn(string $column, array $values) Set a "where not in" constraint on the query. | from DatabaseRule |
$this | using(Closure $callback) Register a custom query callback. | from DatabaseRule |
array | queryCallbacks() Get the custom query callbacks for the rule. | from DatabaseRule |
string | formatWheres() Format the where clauses. | from DatabaseRule |
$this | ignore(mixed $id, string|null $idColumn = null) Ignore the given ID during the unique check. | |
$this | ignoreModel(Model $model, string|null $idColumn = null) Ignore the given model during the unique check. | |
string | __toString() Convert the rule to a validation string. |
Details
void __construct(string $table, string $column = 'NULL')
Create a new rule instance.
string resolveTableName(string $table)
Resolves the name of the table from the given string.
$this where(Closure|string $column, array|string|int|null $value = null)
Set a "where" constraint on the query.
$this whereNot(string $column, array|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 whereIn(string $column, array $values)
Set a "where in" constraint on the query.
$this whereNotIn(string $column, array $values)
Set a "where not in" constraint on the query.
$this using(Closure $callback)
Register a custom query callback.
array queryCallbacks()
Get the custom query callbacks for the rule.
protected string formatWheres()
Format the where clauses.
$this ignore(mixed $id, string|null $idColumn = null)
Ignore the given ID during the unique check.
$this ignoreModel(Model $model, string|null $idColumn = null)
Ignore the given model during the unique check.
string __toString()
Convert the rule to a validation string.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/8.x/Illuminate/Validation/Rules/Unique.html