0038-laravel-eloquent-relationships
CommunityLoad Laravel relationships efficiently.
AuthorMrJmpl3
Version1.0.0
Installs0
System Documentation
What problem does it solve?
Prevents slow Laravel pages caused by inefficient Eloquent relationship loading and N+1 query patterns, while keeping relationship behavior correct and predictable.
Core Features & Use Cases
- N+1-safe eager loading: Use
with()and filtered eager loading to fetch only the needed related records and avoid per-row queries. - Efficient aggregates and counts: Prefer
withCount,withSum,withMaxfor common summary needs without loading full related collections. - Safe pivot operations: Update many-to-many links atomically with
sync()and add without detaching withsyncWithoutDetaching().
Quick Start
Apply constrained eager loading with with() plus withCount() for a paginated endpoint so the ORM returns posts with their author and tags while also including a comments count without triggering N+1 queries.
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: 0038-laravel-eloquent-relationships Download link: https://github.com/MrJmpl3/codex_____data_____configuration/archive/main.zip#0038-laravel-eloquent-relationships 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.