0009-laravel-api-resource-patterns

Community

Ship clean, efficient Laravel API Resources.

AuthorMrJmpl3
Version1.0.0
Installs0

System Documentation

What problem does it solve?

Laravel API Resources often become inconsistent, inefficient, and hard to maintain when relationships are loaded incorrectly, conditional fields are missing, and pagination/meta details are forgotten.

Core Features & Use Cases

  • Consistent Resource Transformations: Map model attributes to API-friendly JSON with clear formatting for dates and primitives.
  • Relationship-Safe Serialization: Use whenLoaded for single and nested relationships to prevent N+1 query problems and avoid unintended lazy loading.
  • Conditional Attributes and Merged Fields: Use when, mergeWhen, and pivot helpers like whenPivotLoaded / whenPivotLoadedAs to include fields only when appropriate.
  • Resource Collections with Pagination Meta & Links: Provide standardized collection responses including pagination metadata and HATEOAS-style links.
  • Response Customization: Return resources with custom HTTP status codes and headers for better REST behavior.
  • Context-Specific Resource Design: Keep resources focused by splitting list/detail variants rather than mixing responsibilities.

Quick Start

Apply the patterns in 0009-laravel-api-resource-patterns to update your JSON responses so relationships are only serialized when loaded, conditional fields behave correctly, and collection endpoints return pagination meta plus links.

Dependency Matrix

Required Modules

None required

Components

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: 0009-laravel-api-resource-patterns
Download link: https://github.com/MrJmpl3/codex_____data_____configuration/archive/main.zip#0009-laravel-api-resource-patterns

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.