laravel-api-resources

Design Laravel API resources, collections, and versioned controllers for JSON endpoints.

Updated Feb 3, 2026
One-click install
npx skills add https://github.com/krlmrr/laravel-playground --skill laravel-api-resources
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel-api-resources
Source: https://github.com/krlmrr/laravel-playground/tree/main/.claude/skills/laravel-api-resources
Command: npx skills add https://github.com/krlmrr/laravel-playground --skill laravel-api-resources

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Designing scalable Laravel APIs requires consistent resources, resource collections, and versioned controllers. This skill provides proven patterns for Eloquent resources, nested relationships, and standardized JSON responses to reduce boilerplate and improve API quality.

Core Features & Use Cases

  • Automates the setup of UserResource, UserCollection, and versioned controllers with clear conventions.
  • Standardizes response shapes, supports nested resources, conditional attributes, pagination, and API versioning.
  • Useful for building resilient, versioned APIs across V1, V2, and beyond with maintainable code.

Quick Start

Create a sample UserResource and UserCollection and wire them into a versioned API route to start serving JSON responses.

Frequently Asked Questions about laravel-api-resources

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

FAQPage Schema
How do I structure Laravel API resources for consistent JSON responses?

Laravel API resources structure consistent JSON responses by wrapping Eloquent models in resource classes and collections. This skill provides patterns for standardized response shapes, nested relationships, and conditional attributes across versioned controllers.

What is the best way to version Laravel API controllers and resources?

Versioning Laravel API controllers involves organizing routes and resources by version, such as V1 and V2. This skill enforces patterns for maintaining multiple API versions, ensuring backward compatibility while managing evolving JSON response structures.

How do I handle nested Eloquent relationships and pagination in Laravel API resources?

Handling nested Eloquent relationships and pagination in Laravel API resources requires applying eager loading patterns and resource collections. This skill enforces conventions for paginated responses and nested resource formatting to prevent N+1 query issues.

Can I use conditional attributes in Laravel JSON resources to hide empty fields?

Conditional attributes in Laravel JSON resources allow you to dynamically include or hide fields based on model state. This skill applies these patterns to standardize response shapes and reduce payload overhead across API endpoints.

Does this approach support building maintainable APIs across multiple versions?

Building maintainable APIs across multiple versions is supported through versioned controllers and resource collections. This skill standardizes conventions for V1, V2, and beyond, reducing boilerplate while improving API quality and code resilience.