spatie/laravel-query-builder

Easily build Eloquent queries from API requests

View on GitHub ↗Jump to charts ↓

Summary Information

Updated 51 minutes ago
Added to GitGenius on September 15th, 2026
Created on January 15th, 2018
Open Issues & Pull Requests: 0 (+0)
GitHub issues: Enabled
Number of forks: 420
Total Stargazers: 4,469 (+0)
Total Subscribers: 47 (+0)

Repository Insights (GitGenius)

Median issue/PR response: 5.4 days
Mean response time: 28.2 days
90th percentile: 94.8 days
Tracked items: 20

Most active contributors

Sign in to see contributor activity.

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Open issues: 0
New in 7 days: 0
Closed in 7 days: 0
Avg open age: N/A days
Stale 30+ days: 0
Stale 90+ days: 0

Recent activity

Opened in 7 days: 0
Closed in 7 days: 0
Comments in 7 days: 0
Events in 7 days: 0

Top labels

  • bug (1)
  • next major (1)

Most active issues this week

No issue events were indexed in the last 7 days.

Detailed Description

Laravel Query Builder is a PHP package that builds Eloquent queries from API requests.

The package solves the problem of translating API request parameters into database queries by providing a declarative syntax for filtering, sorting, including relationships, and selecting fields. Rather than manually parsing query strings and constructing Eloquent queries, developers define which filters, sorts, includes, and fields are allowed, then pass the request to the query builder. It supports filtering with partial matches, exact matches, and custom scopes; grouping filters with OR and AND operators; including nested relationships and relationship counts; sorting in multiple directions; and selecting specific fields per resource.

Teams building REST or JSON:API endpoints should adopt this tool when they need to expose query capabilities safely without manually validating and constructing each query variant. It works well with existing Eloquent queries, allowing you to apply additional constraints before passing the query to the builder. The package is particularly suited to projects that want to follow JSON:API conventions for filtering and sorting. The documentation distinguishes between different filter types and provides examples of custom implementations, suggesting it handles both simple and specialized query requirements.

The project maintains a comprehensive test suite and publishes a changelog documenting changes. Documentation is hosted separately and kept current with the package versions. The team provides a security contact for vulnerability reports rather than using the public issue tracker, indicating attention to security concerns. Contributing guidelines are established, and the project accepts community contributions.