packages-larajs-query

Query Eloquent models dynamically with filtering, sorting, and relationship inclusion.

2|Updated Sep 30, 2024
One-click install
npx skills add https://github.com/maingocthanhtan96/larajs-docs --skill packages-larajs-query
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: packages-larajs-query
Source: https://github.com/maingocthanhtan96/larajs-docs/tree/main/.claude/skills/packages-larajs-query
Command: npx skills add https://github.com/maingocthanhtan96/larajs-docs --skill packages-larajs-query

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill simplifies dynamic querying of Eloquent models, allowing for complex filtering, sorting, searching, and relationship inclusion based on request parameters, reducing boilerplate code.

Core Features & Use Cases

  • Dynamic Filtering: Supports a wide range of operators like equals, lessThan, greaterThan, contains, startsWith, endsWith, any, between, relation, not, has, or, and.
  • Advanced Sorting: Enables sorting by attributes, relationships, and relationship counts.
  • Relationship Management: Includes options for including nested relationships with aggregates and filtering relationships.
  • Use Case: An e-commerce API can use this Skill to allow clients to filter products by price range, sort them by rating, and include related review data, all through simple URL parameters.

Quick Start

Apply LaraJS Query to a Category model query using the provided request parameters and allow list.

Frequently Asked Questions about packages-larajs-query

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

FAQPage Schema
How do I dynamically filter Laravel Eloquent models based on API request parameters?

You can filter Eloquent models by applying operators like equals, contains, startsWith, or between directly to your query builder. This approach maps API request parameters to structured repository pattern queries, eliminating manual boilerplate filtering code.

Can I sort Eloquent query results by relationship attributes and counts?

Yes, advanced sorting enables ordering Eloquent query results by model attributes, relationship attributes, and relationship counts. Clients can sort records based on related data metrics through simple URL parameter requests against the API endpoint.

What is the best way to include nested relationships with aggregates in a Laravel API?

Relationship management features allow including nested relationships with aggregates and filtering within Eloquent queries. This enables API endpoints to return related data and computed aggregates alongside the primary model collection through URL parameters.

Does this dynamic query builder support partial match searching and date filtering?

Yes, the query builder supports partial match searching, date filtering, and field selection for Eloquent models. It handles complex API filtering scenarios including between operators for ranges and various pagination types for structured data retrieval.

How do I implement repository pattern data access for dynamic API filtering in Laravel?

You integrate dynamic query building with the repository pattern by applying request parameters and an allow list to Eloquent model queries. This structures data access while supporting attribute filtering, sorting, and relationship inclusion for API responses.