class Exists implements Stringable

Traits

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

Methods

mixed
when(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

mixed
unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

__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.

where(Closure|string $column, mixed $value = null)

Set a "where" constraint on the query.

whereNot(string $column, mixed $value)

Set a "where not" constraint on the query.

whereNull(string $column)

Set a "where null" constraint on the query.

whereNotNull(string $column)

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

whereIn(string $column, array|Arrayable|BackedEnum $values)

Set a "where in" constraint on the query.

whereNotIn(string $column, array|Arrayable|BackedEnum $values)

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

withoutTrashed(string $deletedAtColumn = 'deleted_at')

Ignore soft deleted models during the existence checks.

onlyTrashed(string $deletedAtColumn = 'deleted_at')

Only include soft deleted models during the existence check.

using(Closure $callback)

Register a custom query callback.

array
queryCallbacks()

Get the custom query callbacks for the rule.

mixed
normalizeWhereValue(mixed $value)

Normalize a where value for string serialization.

string
formatWheres()

Format the where clauses.

string
__toString()

Convert the rule to a validation string.

Details

in Conditionable at line 23
mixed when(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

in Conditionable at line 56
mixed unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

in DatabaseRule at line 40
__construct(string $table, string $column = 'NULL')

Create a new rule instance.

Parameters

string $table
string $column

in DatabaseRule at line 50
string resolveTableName(string $table)

Resolves the name of the table from the given string.

Parameters

string $table

Return Value

string

in DatabaseRule at line 74
DatabaseRule where(Closure|string $column, mixed $value = null)

Set a "where" constraint on the query.

Parameters

Closure|string $column
mixed $value

Return Value

DatabaseRule

in DatabaseRule at line 98
DatabaseRule whereNot(string $column, mixed $value)

Set a "where not" constraint on the query.

Parameters

string $column
mixed $value

Return Value

DatabaseRule

in DatabaseRule at line 112
DatabaseRule whereNull(string $column)

Set a "where null" constraint on the query.

Parameters

string $column

Return Value

DatabaseRule

in DatabaseRule at line 120
DatabaseRule whereNotNull(string $column)

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

Parameters

string $column

Return Value

DatabaseRule

in DatabaseRule at line 128
DatabaseRule whereIn(string $column, array|Arrayable|BackedEnum $values)

Set a "where in" constraint on the query.

Parameters

string $column
array|Arrayable|BackedEnum $values

Return Value

DatabaseRule

in DatabaseRule at line 138
DatabaseRule whereNotIn(string $column, array|Arrayable|BackedEnum $values)

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

Parameters

string $column
array|Arrayable|BackedEnum $values

Return Value

DatabaseRule

in DatabaseRule at line 148
DatabaseRule withoutTrashed(string $deletedAtColumn = 'deleted_at')

Ignore soft deleted models during the existence checks.

Parameters

string $deletedAtColumn

Return Value

DatabaseRule

in DatabaseRule at line 158
DatabaseRule onlyTrashed(string $deletedAtColumn = 'deleted_at')

Only include soft deleted models during the existence check.

Parameters

string $deletedAtColumn

Return Value

DatabaseRule

in DatabaseRule at line 168
DatabaseRule using(Closure $callback)

Register a custom query callback.

Parameters

Closure $callback

Return Value

DatabaseRule

in DatabaseRule at line 178
array queryCallbacks()

Get the custom query callbacks for the rule.

Return Value

array

in DatabaseRule at line 186
protected mixed normalizeWhereValue(mixed $value)

Normalize a where value for string serialization.

Parameters

mixed $value

Return Value

mixed

in DatabaseRule at line 196
protected string formatWheres()

Format the where clauses.

Return Value

string

at line 18
string __toString()

Convert the rule to a validation string.

Return Value

string