laravel-query-builder

Configure Spatie QueryBuilder filters, sorts, and includes for Laravel API endpoints.

3|2|Updated Nov 4, 2025
One-click install
npx skills add https://github.com/y-l-g/saasterkit --skill laravel-query-builder-y-l-g
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel-query-builder
Source: https://github.com/y-l-g/saasterkit/tree/main/.agents/skills/laravel-query-builder
Command: npx skills add https://github.com/y-l-g/saasterkit --skill laravel-query-builder-y-l-g

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill enables developers to rapidly create robust API endpoints by leveraging Spatie's Laravel Query Builder to support filtering, sorting, and including related resources, reducing boilerplate and increasing query safety and consistency.

Core Features & Use Cases

  • Build endpoints that accept filter, sort, include, and fields parameters
  • Configure AllowedFilter, AllowedSort, and AllowedInclude
  • Implement custom filters, sorts, and includes
  • Troubleshoot common Query Builder exceptions in production scenarios

Quick Start

Create an API endpoint for users that supports filters, sorts, and includes using Spatie QueryBuilder.

Frequently Asked Questions about laravel-query-builder

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build Laravel API endpoints with filtering, sorting, and includes?

Laravel API endpoints with filtering, sorting, and includes are built by configuring Spatie QueryBuilder with AllowedFilter, AllowedSort, and AllowedInclude to dynamically query Eloquent models and reduce boilerplate.

How does Spatie QueryBuilder handle dynamic querying and field selection?

Spatie QueryBuilder handles dynamic querying and field selection by accepting filter, sort, include, and fields parameters from API requests, applying them safely to Eloquent models, and ensuring robust input validation and clear error handling.

Can I implement custom filters and sorts for Laravel Eloquent models?

Yes, you can implement custom filters and sorts for Laravel Eloquent models by extending the AllowedFilter and AllowedSort configurations within the Spatie QueryBuilder package to match specific endpoint requirements.

What is the best way to troubleshoot common Laravel Query Builder exceptions in production?

Troubleshooting common Laravel Query Builder exceptions in production involves ensuring safe defaults, validating allowed includes and filters explicitly, and relying on robust error handling patterns provided by the Spatie QueryBuilder configuration.

Do I need Spatie QueryBuilder to create safe API endpoints in Laravel?

While not strictly required, using Spatie QueryBuilder to create API endpoints in Laravel ensures safe defaults, reduces boilerplate for dynamic querying, and provides robust input validation for filters and sorts.