laravel-query-builder

Configure Spatie Laravel Query Builder filters, sorts, includes, and fields for API endpoints.

Updated May 29, 2026
One-click install
npx skills add https://github.com/alimarchal/school --skill laravel-query-builder
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel-query-builder
Source: https://github.com/alimarchal/school/tree/main/.agents/skills/laravel-query-builder
Command: npx skills add https://github.com/alimarchal/school --skill laravel-query-builder

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill enables developers to assemble robust API endpoints by leveraging Spatie's Laravel Query Builder to apply filters, sorts, includes, and field selections in a consistent, predictable way, reducing boilerplate and errors.

Core Features & Use Cases

  • Configures allowedFilters, allowedSorts, allowedIncludes, and allowedFields to control query parameters
  • Supports advanced features such as relation filters, nested includes, custom filters and sorts, and aggregate includes
  • Provides guidance for common patterns like starting from existing queries and dynamically composing filters and sorts for common API scenarios

Quick Start

Create an API endpoint for users that supports filter, sort, and include using Spatie's Laravel Query Builder.

Frequently Asked Questions about laravel-query-builder

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

FAQPage Schema
How do I add API filtering and sorting to my Laravel application?

API filtering and sorting in Laravel is handled by configuring Spatie's Laravel Query Builder to apply allowed filters, sorts, and includes to your queries, reducing boilerplate and controlling query parameters consistently.

What is the best way to handle nested relationship includes in a Laravel API?

Handling nested relationship includes in a Laravel API is achieved by defining allowed includes in the query builder, which supports relation filters, nested includes, and aggregate includes for related data without manual joins.

Can I use custom filters and sorts with Laravel Query Builder?

Yes, you can use custom filters and sorts with Laravel Query Builder. The skill provides guidance for dynamically composing custom filters and sorts to handle common API scenarios and enforce controlled query parameters.

Does Laravel Query Builder support field selection for API responses?

Yes, Laravel Query Builder supports field selection for API responses. You can configure allowed fields to control exactly which data attributes are returned, ensuring predictable and controlled query parameters.

How do I dynamically compose filters from existing queries in Laravel?

You can dynamically compose filters from existing queries in Laravel by starting from your existing query builder instance and applying Spatie's package to dynamically add allowed filters and sorts for common API scenarios.