Overview
TheQueryBuilder class provides a fluent interface for building and executing queries against your spreadsheet data. It supports filtering, sorting, joining, grouping, and aggregation operations.
Creating a Query Builder
Select Methods
select()
select()
distinct()
distinct()
Where Clauses
where()
where()
Add a basic where clause to filter results.
Column name to filter
Comparison operator:
==, ===, !=, <, >, <=, >= (defaults to == if value is provided as second argument)Value to compare against
Returns the query builder for chaining
orWhere()
orWhere()
whereIn()
whereIn()
whereNotIn()
whereNotIn()
whereNull()
whereNull()
whereNotNull()
whereNotNull()
whereBetween()
whereBetween()
Joins
join()
join()
leftJoin()
leftJoin()
Ordering & Limiting
orderBy()
orderBy()
limit()
limit()
offset()
offset()
Grouping & Aggregation
groupBy()
groupBy()
having()
having()
Retrieval Methods
get()
get()
Execute the query and get results as a Collection.
Returns a Collection of results (or Model instances if using a Model query)
first()
first()
Retrieve the first result.
Returns the first result or null if no results found
pluck()
pluck()
count()
count()
exists()
exists()
Check if any matching records exist.
Returns true if at least one record matches, false otherwise
paginate()
paginate()
Retrieve paginated results.
Items per page, or options object with
perPage and page propertiesCurrent page number
Returns pagination object with properties:
data: Collection of items for current pagetotal: Total number of matching recordsper_page: Items per pagecurrent_page: Current page numberlast_page: Last page numberfrom: First item number on page (or null)to: Last item number on page (or null)
Write Operations
insert()
insert()
update()
update()
updateById()
updateById()
delete()
delete()
deleteById()
deleteById()
deleteRow()
deleteRow()
increment()
increment()
decrement()
decrement()
Aggregates
sum()
sum()
avg()
avg()
max()
max()
min()
min()
Advanced Features
with()
with()
scope()
scope()