Download the PHP package lutfi-nur/query-builder without Composer
On this page you can find all versions of the php package lutfi-nur/query-builder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lutfi-nur/query-builder
More information about lutfi-nur/query-builder
Files in lutfi-nur/query-builder
Package query-builder
Short Description Fluent datatable query builder for Laravel with Yajra Datatables. Supports MySQL and PostgreSQL.
License MIT
Informations about the package query-builder
LutfiNur/QueryBuilder
A fluent datatable query builder for Laravel with Yajra Datatables. Supports MySQL and PostgreSQL with automatic driver detection.
Requirements
- PHP >= 8.1
- Laravel >= 10.0
- yajra/laravel-datatables-oracle >= 10.0
Installation
No service provider registration or config publishing required.
This package is zero overhead — classes are only loaded when dtBuilder() is called.
Quick Start
1. Add the Trait to Your Model
2. Create a Datatable Method
3. Define a Route
API Reference
Column Builders
| Method | Description |
|---|---|
addDateColumn($column, $format, $alias) |
Date format (DATE_FORMAT / TO_CHAR) |
addBoolColumn($column, $true, $false, $trueClass, $falseClass) |
Boolean column → generates {col}_str + {col}_class |
addFileColumn($alias, $baseUrl, $source, $default) |
File link with NULL fallback (IFNULL / COALESCE) |
addConcatColumn($alias, $prefix, $column) |
CONCAT without fallback |
addAliasColumn($alias, $expression) |
Alias from a joined table |
addRawColumn($alias, $expression, $searchable) |
Raw SQL expression. Set $searchable = false to exclude from global search |
Filters
All filters read from $request->input('filter').
| Method | Description |
|---|---|
applyRangeFilter($model, $request, $column, $dbColumn?) |
Range filter using filter[{col}_dari] and filter[{col}_sampai] |
applyExactFilters($model, $request, $columns) |
Exact match filter (parameterized, SQL injection safe) |
applyNullFilter($model, $request, $column, $filterParam) |
NULL / NOT NULL filter. filter[$param] == 1 → whereNotNull, otherwise whereNull |
Build
| Method | Description |
|---|---|
buildSelect() |
Returns an Eloquent Builder with table.* + all computed columns |
buildDatatable($model) |
Returns a Yajra Datatable JSON response with global search |
Getters
| Method | Description |
|---|---|
grammar() |
Get the current GrammarInterface instance for building driver-aware expressions |
getColumns() |
Get all registered column expressions |
getModelFilter() |
Get the list of searchable aliases |
getTable() |
Get the table name |
Date Format
Format strings use MySQL specifiers as the standard. For PostgreSQL, conversion is automatic.
| MySQL | PostgreSQL | Description |
|---|---|---|
%Y |
YYYY |
Year (4-digit) |
%y |
YY |
Year (2-digit) |
%m |
MM |
Month (01-12) |
%d |
DD |
Day (01-31) |
%e |
FMDD |
Day (1-31, no leading zero) |
%H |
HH24 |
Hour (00-23) |
%h |
HH12 |
Hour (01-12) |
%i |
MI |
Minute (00-59) |
%s |
SS |
Second (00-59) |
%M |
FMMonth |
Full month name |
%b |
Mon |
Abbreviated month |
%W |
FMDay |
Full weekday name |
%a |
Dy |
Abbreviated weekday |
%p |
AM |
AM/PM |
Database Support
| Driver | Status | Grammar Class |
|---|---|---|
| MySQL | Supported | MySqlGrammar |
| MariaDB | Supported | MySqlGrammar |
| PostgreSQL | Supported | PostgresGrammar |
The database driver is automatically detected from the active Laravel database connection.
Custom Grammar
To support additional drivers (e.g., SQL Server), create a class that implements GrammarInterface and register it in your AppServiceProvider::boot():
Generated SQL Examples
MySQL
PostgreSQL
How It Works
- No ServiceProvider — Pure PSR-4 autoload. Classes are only loaded by PHP when first used.
- Auto driver detection — Grammar is resolved from
DB::connection()->getDriverName()at build time. - Global search — Covers all computed (searchable) columns + model
$fillablecolumns. - Parameterized queries — All search and filter values use parameter binding (SQL injection safe).
searchableflag — Columns added withsearchable: falseare included in SELECT but excluded from global search. Useful for IDs, CSS classes, or display-only expressions.
License
MIT
All versions of query-builder with dependencies
illuminate/database Version ^10.0|^11.0|^12.0|^13.0
illuminate/http Version ^10.0|^11.0|^12.0|^13.0
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
yajra/laravel-datatables-oracle Version ^10.0|^11.0|^12.0|^13.0