Overtrue\Validation\Validator::validateUnique PHP Method

validateUnique() protected method

If a database column is not specified, the attribute will be used.
protected validateUnique ( string $attribute, mixed $value, array $parameters ) : boolean
$attribute string
$value mixed
$parameters array
return boolean
    protected function validateUnique($attribute, $value, $parameters)
    {
        $this->requireParameterCount(1, $parameters, 'unique');
        $table = $parameters[0];
        // The second parameter position holds the name of the column that needs to
        // be verified as unique. If this parameter isn't specified we will just
        // assume that this column to be verified shares the attribute's name.
        $column = isset($parameters[1]) ? $parameters[1] : $attribute;
        list($idColumn, $id) = [null, null];
        if (isset($parameters[2])) {
            list($idColumn, $id) = $this->getUniqueIds($parameters);
            if (strtolower($id) === 'null') {
                $id = null;
            }
        }
        // The presence verifier is responsible for counting rows within this store
        // mechanism which might be a relational database or any other permanent
        // data store like Redis, etc. We will use it to determine uniqueness.
        $verifier = $this->getPresenceVerifier();
        $extra = $this->getUniqueExtra($parameters);
        return $verifier->getCount($table, $column, $value, $id, $idColumn, $extra) === 0;
    }
Validator