PHPackages                             larajs/query - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. larajs/query

ActiveLibrary[Database &amp; ORM](/categories/database)

larajs/query
============

2.0.1(1mo ago)41PHPPHP ^8.3

Since Jul 6Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/maingocthanhtan96/larajs-query)[ Packagist](https://packagist.org/packages/larajs/query)[ RSS](/packages/larajs-query/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (9)Dependencies (8)Versions (14)Used By (0)

   outline deep   title LaraJS Query - Dynamic API Query Builder for Laravel   description LaraJS Query simplifies Eloquent models filtering, sorting, and including relationships with a flexible interface for client-side querying in Laravel applications   author LaraJS Team   head       meta

    name content     keywords

 LaraJS Query, Laravel query builder, Laravel filtering, API query builder, Laravel sorting, Laravel relationships, Eloquent query builder, Laravel pagination, dynamic filtering, Laravel API, Eloquent models, Laravel repository pattern

    meta

    name content     robots

 index, follow

    meta

    name content     twitter:card

 summary_large_image

    meta

    name content     twitter:title

 LaraJS Query - Dynamic API Query Builder for Laravel

    meta

    name content     twitter:description

 Build powerful and flexible Laravel Eloquent queries with LaraJS Query for dynamic filtering, sorting, and relationship handling

    meta

    name content     twitter:image

    meta

    property content     og:title

 LaraJS Query - Dynamic API Query Builder for Laravel

    meta

    property content     og:description

 Build powerful and flexible Laravel Eloquent queries with LaraJS Query for dynamic filtering, sorting, and relationship handling

    meta

    property content     og:url

    meta

    property content     og:image

    meta

    property content     og:type

 article

    link

    rel href     canonical

    LaraJS Query
============

[](#larajs-query)

Dynamic HTTP query parameter builder for Laravel Eloquent. Filter, sort, search, include relationships, select fields, and paginate using a functional query syntax.

Installation
------------

[](#installation)

```
composer require larajs/query:^2.0
```

**Requirements**: PHP 8.3+, Laravel 11/12/13

Quick Start
-----------

[](#quick-start)

```
use App\Models\User;
use LaraJS\Query\LaraJSQuery;
use LaraJS\Query\DTO\{QueryParserAllowDTO, QueryParserRequestDTO};

class UserController
{
    use LaraJSQuery;

    public function index(Request $request)
    {
        return User::query()
            ->applyLaraJSQuery(
                QueryParserRequestDTO::fromArray($request->query()),
                QueryParserAllowDTO::fromArray([
                    'filter' => ['name', 'email'],
                    'include' => ['posts', 'roles'],
                    'sort' => ['name', 'created_at'],
                ])
            )
            ->get();
    }
}
```

**Usage**:

```
GET /api/users?filter=equals(name,'John')&sort=name&include[]=posts&pagination[limit]=10
```

Filtering
---------

[](#filtering)

Filter with functional IBM-style syntax. All filters support relationship variants (e.g., `equalsRelation`, `greaterThanRelation`).

**Function****Example**`equals``?filter=equals(name,'Smith')``greaterThan` / `lessThan``?filter=greaterThan(age,'25')``greaterOrEqual` / `lessOrEqual``?filter=greaterOrEqual(price,'100')``contains` / `startsWith` / `endsWith``?filter=contains(title,'Laravel')``any``?filter=any(status,'active','pending')``between``?filter=between(created_at,'2025-01-01','2025-12-31')``has``?filter=has(posts,'1')``relation``?filter=relation(author,equals(country,'US'))``and` / `or` / `not``?filter=and(equals(role,'admin'),greaterThan(age,'25'))`Sorting
-------

[](#sorting)

Sort by single/multiple columns, including relationships via BelongsToThrough.

**Type****Example**Ascending`?sort=name`Descending`?sort=-name`Multiple`?sort=name,-created_at`Relationship`?sort=author.name`Relationship Count`?sort=posts_count`Searching
---------

[](#searching)

LIKE-based search across columns and relationships.

**Type****Example**Single column`?search[column]=name&search[value]=john`Multiple columns`?search[column]=name,email&search[value]=john`Relationship`?search[column]=author.name&search[value]=smith`Including Relationships
-----------------------

[](#including-relationships)

Eager load relationships with nested support, aggregates, and filtering.

**Type****Example**Single`?include[]=posts`Multiple`?include[]=posts&include[]=roles`Nested`?include[]=posts.comments`Aggregates`?include[]=posts|count&include[]=roles|exists`Filtered`?include[]=posts|and(equals(status,'published'))`Supported aggregates: `count`, `exists`, `sum`, `min`, `max`, `avg`

Selecting Fields
----------------

[](#selecting-fields)

Project specific columns via select parameter.

```
?select=id,name,email

```

Date Filtering
--------------

[](#date-filtering)

Filter by date ranges. Auto-calculates startOfDay/endOfDay boundaries.

**Type****Example**Array format`?date[column]=created_at&date[value][0]=2025-01-01&date[value][1]=2025-12-31`Filter syntax`?filter=between(created_at,'2025-01-01','2025-12-31')`Pagination
----------

[](#pagination)

Three pagination types with configurable limits (default 25, max 500).

**Type****Example**Default`?pagination[limit]=25&pagination[page]=1`Simple`?pagination[type]=simple&pagination[limit]=25&pagination[page]=1`Cursor`?pagination[type]=cursor&pagination[cursor]=...`Security: Allow-List Whitelisting
---------------------------------

[](#security-allow-list-whitelisting)

Control queryable fields for each endpoint. By default, nothing is exposed — explicitly whitelist what clients can query.

```
$allow = QueryParserAllowDTO::fromArray([
    ‘field’   => [‘id’, ‘name’, ‘email’],         // Projectable columns
    ‘filter’  => [‘name’, ‘email’, ‘status’],     // Filterable fields
    ‘sort’    => [‘name’, ‘created_at’],          // Sortable columns
    ‘include’ => [‘posts’, ‘roles’],              // Includable relations
    ‘search’  => [‘name’, ‘email’],               // Searchable fields
    ‘date’    => [‘created_at’],                  // Date-filterable fields
]);
```

Repository Pattern
------------------

[](#repository-pattern)

Use repositories to separate business logic from HTTP concerns.

```
// Repository
class UserRepository extends ReadRepository
{
    public function __construct()
    {
        parent::__construct(new User(), 25, 500);
    }
}

// Controller
class UserController
{
    public function __construct(private UserRepository $users) {}

    public function index(Request $request)
    {
        return $this->users->findAll(
            QueryParserAllowDTO::fromArray([...])
        );
    }
}
```

See `/docs/deployment-guide.md` for complete repository patterns.

Documentation
-------------

[](#documentation)

- **[Official Docs](https://docs.larajs.com/packages/larajs-query.html)** — Full online documentation
- **[docs/project-overview-pdr.md](docs/project-overview-pdr.md)** — Project scope, requirements, architecture
- **[docs/system-architecture.md](docs/system-architecture.md)** — Detailed request lifecycle, component interactions
- **[docs/codebase-summary.md](docs/codebase-summary.md)** — File structure, data flow, algorithms
- **[docs/code-standards.md](docs/code-standards.md)** — PHP 8.3 patterns, naming conventions, security
- **[docs/deployment-guide.md](docs/deployment-guide.md)** — Installation, configuration, usage examples
- **[docs/project-roadmap.md](docs/project-roadmap.md)** — v2.0.0 status, planned features, roadmap

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance92

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~45 days

Recently: every ~77 days

Total

9

Last Release

40d ago

Major Versions

1.3.0 → 2.0.02026-04-19

PHP version history (2 changes)1.0.0PHP ^8.1

1.3.0PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/84553090?v=4)[maingocthanhtan96](/maintainers/maingocthanhtan96)[@maingocthanhtan96](https://github.com/maingocthanhtan96)

---

Top Contributors

[![maingocthanhtan96](https://avatars.githubusercontent.com/u/84553090?v=4)](https://github.com/maingocthanhtan96 "maingocthanhtan96 (52 commits)")

---

Tags

larajs-querylaravellaravel-elo

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/larajs-query/health.svg)

```
[![Health](https://phpackages.com/badges/larajs-query/health.svg)](https://phpackages.com/packages/larajs-query)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8733.1M23](/packages/yajra-laravel-oci8)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45344.0k1](/packages/pressbooks-pressbooks)[api-platform/laravel

API Platform support for Laravel

59156.3k10](/packages/api-platform-laravel)[calebdw/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

15104.9k4](/packages/calebdw-larastan)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
