October\Rain\Database\Builder

Overview

Builder class for queries, extends the Eloquent builder class.

Extends
  • Illuminate\Database\Eloquent\Builder
Implements
  • Illuminate\Contracts\Database\Query\Builder
  • Illuminate\Contracts\Database\Eloquent\Builder

Protected Properties

protected array $eagerLoadAttachResultCache

Show inherited protected properties

Inherited Protected Properties

  • $query - The base query builder instance. (defined in Illuminate\Database\Eloquent\Builder)
  • $model - The model being queried. (defined in Illuminate\Database\Eloquent\Builder)
  • $eagerLoad - The relationships that should be eager loaded. (defined in Illuminate\Database\Eloquent\Builder)
  • $macros - All of the globally registered builder macros. (defined in Illuminate\Database\Eloquent\Builder)
  • $localMacros - All of the locally registered builder macros. (defined in Illuminate\Database\Eloquent\Builder)
  • $onDelete - A replacement for the typical delete function. (defined in Illuminate\Database\Eloquent\Builder)
  • $propertyPassthru - The properties that should be returned from query builder. (defined in Illuminate\Database\Eloquent\Builder)
  • $passthru - The methods that should be returned from query builder. (defined in Illuminate\Database\Eloquent\Builder)
  • $scopes - Applied global scopes. (defined in Illuminate\Database\Eloquent\Builder)
  • $removedScopes - Removed global scopes. (defined in Illuminate\Database\Eloquent\Builder)

Public Methods

public __call()

public __call(string $method, array $parameters): mixed 

Dynamically handle calls into the query instance.

public addWhereExistsQuery()

public addWhereExistsQuery($query, $boolean = 'and', $not = false): void

addWhereExistsQuery modifies the Laravel version to strip ORDER BY from the query, which is redundant in this context, also forbidden by the SQL Server driver.

public lists()

public lists(string $column, string|null $key = null): array 

lists gets an array with the values of a given column.

public orSearchWhere()

public orSearchWhere(
    string $term,
    array $columns = [],
    string $mode = 'all'
): static 

orSearchWhere adds an "or search where" clause to the query.

public orSearchWhereRelation()

public orSearchWhereRelation(
    string $term,
    string $relation,
    array $columns = [],
    string $mode = 'all'
): static 

orSearchWhereRelation adds an "or where" clause to a search relationship query.

public paginate()

public paginate(
    int $perPage = null,
    array $columns = [ 0 => '*'],
    string $pageName = 'page',
    int $page = null
): Illuminate\Contracts\Pagination\LengthAwarePaginator 

paginate the given query.

public paginateAtPage()

public paginateAtPage(
    int $perPage,
    int $currentPage
): Illuminate\Contracts\Pagination\LengthAwarePaginator 

paginateAtPage paginates by passing the page number directly

public paginateCustom()

public paginateCustom(
    int $perPage,
    string $pageName
): Illuminate\Contracts\Pagination\LengthAwarePaginator 

paginateCustom paginates using a custom page name.

public searchWhere()

public searchWhere(
    string $term,
    array $columns = [],
    string $mode = 'all'
): static 

searchWhere performs a search on this query for term found in columns.

public searchWhereRelation()

public searchWhereRelation(
    string $term,
    string $relation,
    array $columns = [],
    string $mode = 'all'
): static 

searchWhereRelation performs a search on a relationship query.

public simplePaginate()

public simplePaginate(
    int $perPage = null,
    array $columns = [ 0 => '*'],
    string $pageName = 'page',
    int $currentPage = null
): Illuminate\Contracts\Pagination\Paginator 

simplePaginate the given query into a simple paginator.

public simplePaginateAtPage()

public simplePaginateAtPage(
    int $perPage,
    int $currentPage
): Illuminate\Contracts\Pagination\Paginator 

simplePaginateAtPage simply paginates by passing the page number directly

public simplePaginateCustom()

public simplePaginateCustom(
    int $perPage,
    string $pageName
): Illuminate\Contracts\Pagination\Paginator 

simplePaginateCustom simply paginates using a custom page name.

Show inherited public methods

Inherited Public Methods

  • __callStatic() - Dynamically handle calls into the query instance. (defined in Illuminate\Database\Eloquent\Builder)
  • __clone() - Force a clone of the underlying query builder when cloning. (defined in Illuminate\Database\Eloquent\Builder)
  • __construct() - Create a new Eloquent query builder instance. (defined in Illuminate\Database\Eloquent\Builder)
  • __get() - Dynamically access builder proxies. (defined in Illuminate\Database\Eloquent\Builder)
  • applyScopes() - Apply the scopes to the Eloquent builder instance and return it. (defined in Illuminate\Database\Eloquent\Builder)
  • baseSole() - Execute the query and get the first result if it's the sole matching record. (defined in Illuminate\Database\Eloquent\Builder)
  • chunk() - Chunk the results of the query. (defined in Illuminate\Database\Eloquent\Builder)
  • chunkById() - Chunk the results of a query by comparing IDs. (defined in Illuminate\Database\Eloquent\Builder)
  • chunkMap() - Run a map over each item while chunking. (defined in Illuminate\Database\Eloquent\Builder)
  • clone() - Clone the Eloquent query builder. (defined in Illuminate\Database\Eloquent\Builder)
  • create() - Save a new model and return the instance. (defined in Illuminate\Database\Eloquent\Builder)
  • cursor() - Get a lazy collection for the given query. (defined in Illuminate\Database\Eloquent\Builder)
  • cursorPaginate() - Paginate the given query into a cursor paginator. (defined in Illuminate\Database\Eloquent\Builder)
  • decrement() - Decrement a column's value by a given amount. (defined in Illuminate\Database\Eloquent\Builder)
  • delete() - Delete records from the database. (defined in Illuminate\Database\Eloquent\Builder)
  • doesntHave() - Add a relationship count / exists condition to the query. (defined in Illuminate\Database\Eloquent\Builder)
  • doesntHaveMorph() - Add a polymorphic relationship count / exists condition to the query. (defined in Illuminate\Database\Eloquent\Builder)
  • each() - Execute a callback over each item while chunking. (defined in Illuminate\Database\Eloquent\Builder)
  • eachById() - Execute a callback over each item while chunking by ID. (defined in Illuminate\Database\Eloquent\Builder)
  • eagerLoadRelations() - Eager load the relationships for the models. (defined in Illuminate\Database\Eloquent\Builder)
  • find() - Find a model by its primary key. (defined in Illuminate\Database\Eloquent\Builder)
  • findMany() - Find multiple models by their primary keys. (defined in Illuminate\Database\Eloquent\Builder)
  • findOr() - Find a model by its primary key or call a callback. (defined in Illuminate\Database\Eloquent\Builder)
  • findOrFail() - Find a model by its primary key or throw an exception. (defined in Illuminate\Database\Eloquent\Builder)
  • findOrNew() - Find a model by its primary key or return fresh model instance. (defined in Illuminate\Database\Eloquent\Builder)
  • first() - Execute the query and get the first result. (defined in Illuminate\Database\Eloquent\Builder)
  • firstOr() - Execute the query and get the first result or call a callback. (defined in Illuminate\Database\Eloquent\Builder)
  • firstOrCreate() - Get the first record matching the attributes or create it. (defined in Illuminate\Database\Eloquent\Builder)
  • firstOrFail() - Execute the query and get the first result or throw an exception. (defined in Illuminate\Database\Eloquent\Builder)
  • firstOrNew() - Get the first record matching the attributes or instantiate it. (defined in Illuminate\Database\Eloquent\Builder)
  • firstWhere() - Add a basic where clause to the query, and return the first result. (defined in Illuminate\Database\Eloquent\Builder)
  • forceCreate() - Save a new model and return the instance. Allow mass-assignment. (defined in Illuminate\Database\Eloquent\Builder)
  • forceDelete() - Run the default delete function on the builder. (defined in Illuminate\Database\Eloquent\Builder)
  • fromQuery() - Create a collection of models from a raw query. (defined in Illuminate\Database\Eloquent\Builder)
  • get() - Execute the query as a "select" statement. (defined in Illuminate\Database\Eloquent\Builder)
  • getEagerLoads() - Get the relationships being eagerly loaded. (defined in Illuminate\Database\Eloquent\Builder)
  • getGlobalMacro() - Get the given global macro by name. (defined in Illuminate\Database\Eloquent\Builder)
  • getMacro() - Get the given macro by name. (defined in Illuminate\Database\Eloquent\Builder)
  • getModel() - Get the model instance being queried. (defined in Illuminate\Database\Eloquent\Builder)
  • getModels() - Get the hydrated models without eager loading. (defined in Illuminate\Database\Eloquent\Builder)
  • getQuery() - Get the underlying query builder instance. (defined in Illuminate\Database\Eloquent\Builder)
  • getRelation() - Get the relation instance for the given relation name. (defined in Illuminate\Database\Eloquent\Builder)
  • has() - Add a relationship count / exists condition to the query. (defined in Illuminate\Database\Eloquent\Builder)
  • hasGlobalMacro() - Checks if a global macro is registered. (defined in Illuminate\Database\Eloquent\Builder)
  • hasMacro() - Checks if a macro is registered. (defined in Illuminate\Database\Eloquent\Builder)
  • hasMorph() - Add a polymorphic relationship count / exists condition to the query. (defined in Illuminate\Database\Eloquent\Builder)
  • hasNamedScope() - Determine if the given model has a scope. (defined in Illuminate\Database\Eloquent\Builder)
  • hydrate() - Create a collection of models from plain arrays. (defined in Illuminate\Database\Eloquent\Builder)
  • increment() - Increment a column's value by a given amount. (defined in Illuminate\Database\Eloquent\Builder)
  • latest() - Add an "order by" clause for a timestamp to the query. (defined in Illuminate\Database\Eloquent\Builder)
  • lazy() - Query lazily, by chunks of the given size. (defined in Illuminate\Database\Eloquent\Builder)
  • lazyById() - Query lazily, by chunking the results of a query by comparing IDs. (defined in Illuminate\Database\Eloquent\Builder)
  • lazyByIdDesc() - Query lazily, by chunking the results of a query by comparing IDs in descending order. (defined in Illuminate\Database\Eloquent\Builder)
  • make() - Create and return an un-saved model instance. (defined in Illuminate\Database\Eloquent\Builder)
  • mergeConstraintsFrom() - Merge the where constraints from another query to the current query. (defined in Illuminate\Database\Eloquent\Builder)
  • newModelInstance() - Create a new instance of the model being queried. (defined in Illuminate\Database\Eloquent\Builder)
  • oldest() - Add an "order by" clause for a timestamp to the query. (defined in Illuminate\Database\Eloquent\Builder)
  • onDelete() - Register a replacement for the default delete function. (defined in Illuminate\Database\Eloquent\Builder)
  • orDoesntHave() - Add a relationship count / exists condition to the query with an "or". (defined in Illuminate\Database\Eloquent\Builder)
  • orDoesntHaveMorph() - Add a polymorphic relationship count / exists condition to the query with an "or". (defined in Illuminate\Database\Eloquent\Builder)
  • orHas() - Add a relationship count / exists condition to the query with an "or". (defined in Illuminate\Database\Eloquent\Builder)
  • orHasMorph() - Add a polymorphic relationship count / exists condition to the query with an "or". (defined in Illuminate\Database\Eloquent\Builder)
  • orWhere() - Add an "or where" clause to the query. (defined in Illuminate\Database\Eloquent\Builder)
  • orWhereBelongsTo() - Add an "BelongsTo" relationship with an "or where" clause to the query. (defined in Illuminate\Database\Eloquent\Builder)
  • orWhereDoesntHave() - Add a relationship count / exists condition to the query with where clauses and an "or". (defined in Illuminate\Database\Eloquent\Builder)
  • orWhereDoesntHaveMorph() - Add a polymorphic relationship count / exists condition to the query with where clauses and an "or". (defined in Illuminate\Database\Eloquent\Builder)
  • orWhereHas() - Add a relationship count / exists condition to the query with where clauses and an "or". (defined in Illuminate\Database\Eloquent\Builder)
  • orWhereHasMorph() - Add a polymorphic relationship count / exists condition to the query with where clauses and an "or". (defined in Illuminate\Database\Eloquent\Builder)
  • orWhereMorphRelation() - Add a polymorphic relationship condition to the query with an "or where" clause. (defined in Illuminate\Database\Eloquent\Builder)
  • orWhereMorphedTo() - Add a morph-to relationship condition to the query with an "or where" clause. (defined in Illuminate\Database\Eloquent\Builder)
  • orWhereNot() - Add an "or where not" clause to the query. (defined in Illuminate\Database\Eloquent\Builder)
  • orWhereNotMorphedTo() - Add a not morph-to relationship condition to the query with an "or where" clause. (defined in Illuminate\Database\Eloquent\Builder)
  • orWhereRelation() - Add an "or where" clause to a relationship query. (defined in Illuminate\Database\Eloquent\Builder)
  • pluck() - Get a collection with the values of a given column. (defined in Illuminate\Database\Eloquent\Builder)
  • qualifyColumn() - Qualify the given column name by the model's table. (defined in Illuminate\Database\Eloquent\Builder)
  • qualifyColumns() - Qualify the given columns with the model's table. (defined in Illuminate\Database\Eloquent\Builder)
  • removedScopes() - Get an array of global scopes that were removed from the query. (defined in Illuminate\Database\Eloquent\Builder)
  • scopes() - Call the given local model scopes. (defined in Illuminate\Database\Eloquent\Builder)
  • setEagerLoads() - Set the relationships being eagerly loaded. (defined in Illuminate\Database\Eloquent\Builder)
  • setModel() - Set a model instance for the model being queried. (defined in Illuminate\Database\Eloquent\Builder)
  • setQuery() - Set the underlying query builder instance. (defined in Illuminate\Database\Eloquent\Builder)
  • sole() - Execute the query and get the first result if it's the sole matching record. (defined in Illuminate\Database\Eloquent\Builder)
  • soleValue() - Get a single column's value from the first result of a query if it's the sole matching record. (defined in Illuminate\Database\Eloquent\Builder)
  • tap() - Pass the query to a given callback. (defined in Illuminate\Database\Eloquent\Builder)
  • toBase() - Get a base query builder instance. (defined in Illuminate\Database\Eloquent\Builder)
  • touch() - Update the column's update timestamp. (defined in Illuminate\Database\Eloquent\Builder)
  • unless() - Apply the callback if the given "value" is (or resolves to) falsy. (defined in Illuminate\Database\Eloquent\Builder)
  • update() - Update records in the database. (defined in Illuminate\Database\Eloquent\Builder)
  • updateOrCreate() - Create or update a record matching the attributes, and fill it with values. (defined in Illuminate\Database\Eloquent\Builder)
  • upsert() - Insert new records or update the existing ones. (defined in Illuminate\Database\Eloquent\Builder)
  • value() - Get a single column's value from the first result of a query. (defined in Illuminate\Database\Eloquent\Builder)
  • valueOrFail() - Get a single column's value from the first result of the query or throw an exception. (defined in Illuminate\Database\Eloquent\Builder)
  • when() - Apply the callback if the given "value" is (or resolves to) truthy. (defined in Illuminate\Database\Eloquent\Builder)
  • where() - Add a basic where clause to the query. (defined in Illuminate\Database\Eloquent\Builder)
  • whereBelongsTo() - Add a "belongs to" relationship where clause to the query. (defined in Illuminate\Database\Eloquent\Builder)
  • whereDoesntHave() - Add a relationship count / exists condition to the query with where clauses. (defined in Illuminate\Database\Eloquent\Builder)
  • whereDoesntHaveMorph() - Add a polymorphic relationship count / exists condition to the query with where clauses. (defined in Illuminate\Database\Eloquent\Builder)
  • whereHas() - Add a relationship count / exists condition to the query with where clauses. (defined in Illuminate\Database\Eloquent\Builder)
  • whereHasMorph() - Add a polymorphic relationship count / exists condition to the query with where clauses. (defined in Illuminate\Database\Eloquent\Builder)
  • whereKey() - Add a where clause on the primary key to the query. (defined in Illuminate\Database\Eloquent\Builder)
  • whereKeyNot() - Add a where clause on the primary key to the query. (defined in Illuminate\Database\Eloquent\Builder)
  • whereMorphRelation() - Add a polymorphic relationship condition to the query with a where clause. (defined in Illuminate\Database\Eloquent\Builder)
  • whereMorphedTo() - Add a morph-to relationship condition to the query. (defined in Illuminate\Database\Eloquent\Builder)
  • whereNot() - Add a basic "where not" clause to the query. (defined in Illuminate\Database\Eloquent\Builder)
  • whereNotMorphedTo() - Add a not morph-to relationship condition to the query. (defined in Illuminate\Database\Eloquent\Builder)
  • whereRelation() - Add a basic where clause to a relationship query. (defined in Illuminate\Database\Eloquent\Builder)
  • with() - Set the relationships that should be eager loaded. (defined in Illuminate\Database\Eloquent\Builder)
  • withAggregate() - Add subselect queries to include an aggregate value for a relationship. (defined in Illuminate\Database\Eloquent\Builder)
  • withAvg() - Add subselect queries to include the average of the relation's column. (defined in Illuminate\Database\Eloquent\Builder)
  • withCasts() - Apply query-time casts to the model instance. (defined in Illuminate\Database\Eloquent\Builder)
  • withCount() - Add subselect queries to count the relations. (defined in Illuminate\Database\Eloquent\Builder)
  • withExists() - Add subselect queries to include the existence of related models. (defined in Illuminate\Database\Eloquent\Builder)
  • withGlobalScope() - Register a new global scope. (defined in Illuminate\Database\Eloquent\Builder)
  • withMax() - Add subselect queries to include the max of the relation's column. (defined in Illuminate\Database\Eloquent\Builder)
  • withMin() - Add subselect queries to include the min of the relation's column. (defined in Illuminate\Database\Eloquent\Builder)
  • withOnly() - Set the relationships that should be eager loaded while removing any previously added eager loading specifications. (defined in Illuminate\Database\Eloquent\Builder)
  • withSum() - Add subselect queries to include the sum of the relation's column. (defined in Illuminate\Database\Eloquent\Builder)
  • withWhereHas() - Add a relationship count / exists condition to the query with where clauses. (defined in Illuminate\Database\Eloquent\Builder)
  • without() - Prevent the specified relations from being eager loaded. (defined in Illuminate\Database\Eloquent\Builder)
  • withoutEagerLoad() - Indicate that the given relationships should not be eagerly loaded. (defined in Illuminate\Database\Eloquent\Builder)
  • withoutEagerLoads() - Flush the relationships being eagerly loaded. (defined in Illuminate\Database\Eloquent\Builder)
  • withoutGlobalScope() - Remove a registered global scope. (defined in Illuminate\Database\Eloquent\Builder)
  • withoutGlobalScopes() - Remove all or passed registered global scopes. (defined in Illuminate\Database\Eloquent\Builder)

Protected Methods

protected eagerLoadAttachRelation()

protected eagerLoadAttachRelation(
    string $relatedModel,
    array $models,
    string $name
): array|null 

eagerLoadAttachRelation eagerly loads an attachment relationship on a set of models.

protected eagerLoadRelation()

protected eagerLoadRelation(
    array $models,
    string $name,
    Closure $constraints
): array 

eagerLoadRelation eagerly load the relationship on a set of models, with support for attach relations.

protected searchWhereInternal()

protected searchWhereInternal($term, $columns, $mode, $boolean): void

Internal method to apply a search constraint to the query. Mode can be any of these options:

  • all: result must contain all words
  • any: result can contain any word
  • exact: result must contain the exact phrase

Show inherited protected methods

Inherited Protected Methods

  • addHasWhere() - Add the "has" condition where clause to the query. (defined in Illuminate\Database\Eloquent\Builder)
  • addNestedWiths() - Parse the nested relationships in a relation. (defined in Illuminate\Database\Eloquent\Builder)
  • addNewWheresWithinGroup() - Nest where conditions by slicing them at the given where count. (defined in Illuminate\Database\Eloquent\Builder)
  • addTimestampsToUpsertValues() - Add timestamps to the inserted values. (defined in Illuminate\Database\Eloquent\Builder)
  • addUpdatedAtColumn() - Add the "updated at" column to an array of values. (defined in Illuminate\Database\Eloquent\Builder)
  • addUpdatedAtToUpsertColumns() - Add the "updated at" column to the updated columns. (defined in Illuminate\Database\Eloquent\Builder)
  • addWhereCountQuery() - Add a sub-query count clause to this query. (defined in Illuminate\Database\Eloquent\Builder)
  • callNamedScope() - Apply the given named scope on the current builder instance. (defined in Illuminate\Database\Eloquent\Builder)
  • callScope() - Apply the given scope on the current builder instance. (defined in Illuminate\Database\Eloquent\Builder)
  • canUseExistsForExistenceCheck() - Check if we can run an "exists" query to optimize performance. (defined in Illuminate\Database\Eloquent\Builder)
  • combineConstraints() - Combine an array of constraints into a single constraint. (defined in Illuminate\Database\Eloquent\Builder)
  • createNestedWhere() - Create a where array with nested where conditions. (defined in Illuminate\Database\Eloquent\Builder)
  • createSelectWithConstraint() - Create a constraint to select the given columns for the relation. (defined in Illuminate\Database\Eloquent\Builder)
  • cursorPaginator() - Create a new cursor paginator instance. (defined in Illuminate\Database\Eloquent\Builder)
  • defaultKeyName() - Get the default key name of the table. (defined in Illuminate\Database\Eloquent\Builder)
  • enforceOrderBy() - Add a generic "order by" clause if the query doesn't already have one. (defined in Illuminate\Database\Eloquent\Builder)
  • ensureOrderForCursorPagination() - Ensure the proper order by required for cursor pagination. (defined in Illuminate\Database\Eloquent\Builder)
  • forwardCallTo() - Forward a method call to the given object. (defined in Illuminate\Database\Eloquent\Builder)
  • forwardDecoratedCallTo() - Forward a method call to the given object, returning $this if the forwarded call returned itself. (defined in Illuminate\Database\Eloquent\Builder)
  • getBelongsToRelation() - Get the BelongsTo relationship for a single polymorphic type. (defined in Illuminate\Database\Eloquent\Builder)
  • getOriginalColumnNameForCursorPagination() - Get the original column name of the given column, without any aliasing. (defined in Illuminate\Database\Eloquent\Builder)
  • getRelationHashedColumn() - Get the relation hashed column name for the given column and relation. (defined in Illuminate\Database\Eloquent\Builder)
  • getRelationWithoutConstraints() - Get the "has relation" base query instance. (defined in Illuminate\Database\Eloquent\Builder)
  • groupWhereSliceForScope() - Slice where conditions at the given offset and add them to the query as a nested condition. (defined in Illuminate\Database\Eloquent\Builder)
  • hasNested() - Add nested relationship count / exists conditions to the query. (defined in Illuminate\Database\Eloquent\Builder)
  • isNestedUnder() - Determine if the relationship is nested. (defined in Illuminate\Database\Eloquent\Builder)
  • orderedLazyById() - Query lazily, by chunking the results of a query by comparing IDs in a given order. (defined in Illuminate\Database\Eloquent\Builder)
  • paginateUsingCursor() - Paginate the given query using a cursor paginator. (defined in Illuminate\Database\Eloquent\Builder)
  • paginator() - Create a new length-aware paginator instance. (defined in Illuminate\Database\Eloquent\Builder)
  • parseNameAndAttributeSelectionConstraint() - Parse the attribute select constraints from the name. (defined in Illuminate\Database\Eloquent\Builder)
  • parseWithRelations() - Parse a list of relations into individuals. (defined in Illuminate\Database\Eloquent\Builder)
  • prepareNestedWithRelationships() - Prepare nested with relationships. (defined in Illuminate\Database\Eloquent\Builder)
  • registerMixin() - Register the given mixin with the builder. (defined in Illuminate\Database\Eloquent\Builder)
  • relationsNestedUnder() - Get the deeply nested relations for a given top-level relation. (defined in Illuminate\Database\Eloquent\Builder)
  • requalifyWhereTables() - Updates the table name for any columns with a new qualified name. (defined in Illuminate\Database\Eloquent\Builder)
  • simplePaginator() - Create a new simple paginator instance. (defined in Illuminate\Database\Eloquent\Builder)
  • throwBadMethodCallException() - Throw a bad method call exception for the given method. (defined in Illuminate\Database\Eloquent\Builder)