Fr3nch13/CakePHP Utilities

IsUnique
in package

Checks that a list of fields from an entity are unique in the table

Table of Contents

Properties

$_fields  : array<string|int, string>
The list of fields to check
$_options  : array<string, mixed>
The unique check options

Methods

__construct()  : mixed
Constructor.
__invoke()  : bool
Performs the uniqueness check
_alias()  : array<string, mixed>
Add a model alias to all the keys in a set of conditions.

Properties

$_fields

The list of fields to check

protected array<string|int, string> $_fields

$_options

The unique check options

protected array<string, mixed> $_options = ['allowMultipleNulls' => false]

Methods

__construct()

Constructor.

public __construct(array<string|int, string> $fields[, array<string, mixed> $options = [] ]) : mixed

Options

  • allowMultipleNulls Allows any field to have multiple null values. Defaults to false.
Parameters
$fields : array<string|int, string>

The list of fields to check uniqueness for

$options : array<string, mixed> = []

The options for unique checks.

__invoke()

Performs the uniqueness check

public __invoke(EntityInterface $entity, array<string, mixed> $options) : bool
Parameters
$entity : EntityInterface

The entity from where to extract the fields where the repository key is required.

$options : array<string, mixed>

Options passed to the check,

Return values
bool

_alias()

Add a model alias to all the keys in a set of conditions.

protected _alias(string $alias, array<string|int, mixed> $conditions) : array<string, mixed>
Parameters
$alias : string

The alias to add.

$conditions : array<string|int, mixed>

The conditions to alias.

Return values
array<string, mixed>

        
On this page

Search results