From superpowers-laravel
Defines Eloquent model relationships and loads data efficiently in Laravel: prevents N+1 queries, applies constraints, uses counts/sums aggregates, and handles pivot syncing safely.
npx claudepluginhub jpcaparas/superpowers-laravel --plugin superpowers-laravelThis skill uses the workspace's default tool permissions.
Model relationships express your domain; load only what you need.
Prevents N+1 queries in Laravel by guiding eager relation loading, selective field selection, and non-production lazy-loading protection. Optimizes DB performance.
Applies Laravel Eloquent best practices for query optimization, eager loading to avoid N+1, relationships, mass assignment protection, casts, and chunking large datasets.
Provides expert Laravel patterns for PHP 8.2+ including Eloquent ORM best practices, N+1 prevention, efficient queries, atomic operations, query optimization, and RESTful API controllers.
Share bugs, ideas, or general feedback.
Model relationships express your domain; load only what you need.
# Typical loading
Post::with(['author', 'tags'])->withCount('comments')->paginate(20);
# Constrained eager loading
User::with(['posts' => fn($q) => $q->latest()->where('published', true)])->find($id);
# Pivot ops (many-to-many)
$post->tags()->sync([1,2,3]); // atomic replace
$post->tags()->syncWithoutDetaching([4]);
# Chunking large reads
Order::where('status', 'open')->lazy()->each(fn($o) => ...);
laravel:performance-eager-loading for N+1 detection and measurementwhereHas() / has() to filter by related existencewithCount, withSum, withMax for simple aggregates