Package

Mpyw Compoships Eager Limit

topclaudy/compoships + staudenmeir/eloquent-eager-limit

Package

mpyw/compoships-eager-limit

View on GitHub →

Compoships Eager Limit

topclaudy/compoships + staudenmeir/eloquent-eager-limit

[!WARNING] This package is abandoned and no longer maintained.

staudenmeir/eloquent-eager-limit has been merged into the core since Laravel 11, and PR topclaudy/compoships#180 — which adds native limit()/offset() support to composite-key eager loads — was merged on 2025-10-03 and shipped in topclaudy/compoships ^3.0. Both pieces this wrapper used to glue together are now available upstream, so the package is no longer needed.

Migration: depend on topclaudy/compoships ^3.0 directly and call limit() inside your eager-load closures. On Laravel 11+ no extra trait is required.

$posts = Post::with(['authorComments' => fn ($query) => $query->limit(3)->offset(1)])->get();

Requirements

Installing

composer require mpyw/compoships-eager-limit

Usage

<?php
 
namespace App;
 
use Illuminate\Database\Eloquent\Model;
use Mpyw\ComposhipsEagerLimit\ComposhipsEagerLimit;
 
class Post extends Model
{
use ComposhipsEagerLimit;
 
public function comments()
{
return $this->hasMany(Comment::class);
}
 
public function authorComments()
{
return $this->hasMany(Comment::class, ['post_id', 'user_id'], ['id', 'user_id']);
}
}
<?php
 
namespace App;
 
use Illuminate\Database\Eloquent\Model;
use Mpyw\ComposhipsEagerLimit\ComposhipsEagerLimit;
 
class Comment extends Model
{
use ComposhipsEagerLimit;
}
$posts = Post::with(['authorComments' => function ($query) {
$query->limit(3)->offset(1);
}])->get();

For more details, visit each base package repository.

Special Thanks

Mpyw Compoships Eager Limit Related Articles

Eager Load Limit is Coming to Laravel 11 image

Eager Load Limit is Coming to Laravel 11

Read article
Laravel News 2024 Recap image

Laravel News 2024 Recap

Read article
UnitTest Attribute and More in Laravel 13.3.0 image

UnitTest Attribute and More in Laravel 13.3.0

Read article
Convert Your SQL to Laravel Builder with Orator image

Convert Your SQL to Laravel Builder with Orator

Read article
Verify Nested Relations Efficiently with Laravel's Enhanced relationLoaded Method image

Verify Nested Relations Efficiently with Laravel's Enhanced relationLoaded Method

Read article
Laravel Black Friday Deals image

Laravel Black Friday Deals

Read article
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $9500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
Pushsilver logo

Pushsilver

Pushsilver is simple invoicing for freelancers and small studios — send polished invoices, automate reminders, and get paid on time without the bloat.

Pushsilver
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit