laravel-query-builder

Configure filtering, sorting, and includes for Laravel API endpoints.

1.5k|170|Updated Sep 25, 2024
One-click install
npx skills add https://github.com/relaticle/relaticle --skill laravel-query-builder-relaticle
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel-query-builder
Source: https://github.com/relaticle/relaticle/tree/main/.claude/skills/laravel-query-builder
Command: npx skills add https://github.com/relaticle/relaticle --skill laravel-query-builder-relaticle

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Laravel projects often struggle with building scalable APIs that support dynamic filtering, sorting, and including related data without bespoke, endpoint-specific logic.

Core Features & Use Cases

  • Configurable filters, sorts, and includes via Spatie\QueryBuilder
  • Custom filter, sort, and include extensions for robust API design
  • Use cases include building index endpoints with ?filter, ?sort, ?include, and fields

Quick Start

Create a Laravel API endpoint using QueryBuilder::for(Model::class)->allowedFilters(...)->allowedSorts(...)->allowedIncludes(...) and return results.

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 dynamic filtering and sorting to Laravel API endpoints?

Dynamic filtering and sorting in Laravel APIs is achieved by applying configurable query parameters to Eloquent models using QueryBuilder, allowing safe URL-based manipulation without bespoke endpoint logic.

What is the best way to include related data in Laravel RESTful API responses?

Including related data in Laravel RESTful APIs is handled through allowed includes, letting clients request related Eloquent models via URL parameters while maintaining controlled, secure query execution.

Does this Laravel query builder approach support custom filters and sorts?

Yes, the Laravel query builder approach supports custom filters, sorts, and includes, enabling robust API design through configurable extensions beyond the default Eloquent query parameter handling.

How do I use Spatie QueryBuilder components for Laravel API development?

Spatie QueryBuilder components are used by chaining methods like QueryBuilder::for(Model::class)->allowedFilters(...)->allowedSorts(...)->allowedIncludes(...) to return controlled, filtered results for RESTful endpoints.

Can I select specific fields in Laravel Eloquent API queries?

Yes, specific fields can be selected in Laravel Eloquent API queries through field selection parameters, ensuring clients only retrieve the exact database columns they need from the endpoint response.