0010-laravel-api-resources-and-pagination
CommunityKeep API responses consistent with paginated resources
Software Engineering#laravel#pagination#api resources#response shaping#conditional fields#resource collections#stable contracts
AuthorMrJmpl3
Version1.0.0
Installs0
System Documentation
What problem does it solve?
This Skill helps you keep Laravel API responses stable and client-friendly by using API Resources with pagination and conditional fields, preventing ad-hoc response shapes and leaky transport logic.
Core Features & Use Cases
- Resource-based response shaping: Represent Eloquent models with dedicated Resource classes to separate transport concerns from domain logic.
- Pagination that preserves client expectations: Use Resource::collection with paginated queries so pagination links/cursors and metadata stay intact.
- Conditional, cache-friendly fields: Use when()/mergeWhen() and whenLoaded()/optional() patterns to include fields only when appropriate, avoiding inconsistent output contracts.
Quick Start
Update your controller to return a PostResource::collection wrapping a query that uses paginate(), and implement toArray() in your Resource to output a consistent set of fields with conditional author and published_at handling.
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: 0010-laravel-api-resources-and-pagination Download link: https://github.com/MrJmpl3/codex_____data_____configuration/archive/main.zip#0010-laravel-api-resources-and-pagination Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.