PHPackages                             lastdragon-ru/lara-asp-eloquent - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. lastdragon-ru/lara-asp-eloquent

ActiveLibrary[Database &amp; ORM](/categories/database)

lastdragon-ru/lara-asp-eloquent
===============================

Contains useful extensions and mixins for Eloquent.

10.3.0(2mo ago)1109.5k—8.1%1MITPHPPHP ^8.3|^8.4

Since Jan 19Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/LastDragon-ru/lara-asp-eloquent)[ Packagist](https://packagist.org/packages/lastdragon-ru/lara-asp-eloquent)[ Docs](https://github.com/LastDragon-ru/php-packages)[ RSS](/packages/lastdragon-ru-lara-asp-eloquent/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (22)Versions (84)Used By (1)

(Laravel) Eloquent Helpers
==========================

[](#laravel-eloquent-helpers)

This package contains useful extensions and mixins for [Eloquent](https://laravel.com/docs/eloquent).

Requirements
============

[](#requirements)

RequirementConstraintSupported byPHP`^8.5``HEAD``^8.4``HEAD ⋯ 8.0.0``^8.3``10.3.0 ⋯ 5.0.0``^8.2``7.2.0 ⋯ 2.0.0``^8.1``6.4.2 ⋯ 2.0.0``^8.0``4.6.0 ⋯ 2.0.0``^8.0.0``1.1.2 ⋯ 0.12.0``>=8.0.0``0.11.0 ⋯ 0.4.0``>=7.4.0``0.3.0 ⋯ 0.1.0`Laravel`^12.0.1``HEAD ⋯ 9.0.0``^11.0.8``8.1.1 ⋯ 8.0.0``^11.0.0``7.2.0 ⋯ 6.2.0``^10.34.0``7.2.0 ⋯ 6.2.0``^10.0.0``6.1.0 ⋯ 2.1.0``^9.21.0``5.6.0 ⋯ 5.0.0-beta.1``^9.0.0``5.0.0-beta.0 ⋯ 0.12.0``^8.22.1``3.0.0 ⋯ 0.2.0``^8.0``0.1.0`Installation
============

[](#installation)

```
composer require lastdragon-ru/lara-asp-eloquent
```

Iterators
=========

[](#iterators)

Iterators are similar to `Builder::chunk()` but uses generators instead of `\Closure` that makes code more readable:

```
$query = \App\Models\User::query();

$query->chunk(100, function ($users) {
    foreach ($users as $user) {
        // ...
    }
});

foreach ($query->getChunkedIterator() as $user) {
    // ...
}
```

Iterators also support limit/offset, by default it will try to get them from the Builder, but you can also set them by hand:

```
$query = \App\Models\User::query()->offset(10)->limit(20);

foreach ($query->getChunkedIterator() as $user) {
    // ... 20 items from 10
}

foreach ($query->getChunkedIterator()->setOffset(0) as $user) {
    // ...20 items from 0
}
```

When you use the default [`ChunkedIterator`](./src/Iterators/ChunkedIterator.php) you should not modify/delete the items while iteration or you will get unexpected results (eg missing items). If you need to modify/delete items while iteration you can use [`ChunkedChangeSafeIterator`](./src/Iterators/ChunkedChangeSafeIterator.php) that specially created for this case and unlike standard `chunkById()` it is always safe (please see [laravel/framework#35400](https://github.com/laravel/framework/issues/35400) for more details). But there are few limitations:

- it is not possible to sort rows, they always will be sorted by `column asc`;
- the `column` should not be changed while iteration or this may lead to repeating row in results;
- the row inserted while iteration may be skipped if it has `column` with the value that lover than the internal pointer;
- queries with UNION is not supported;
- `offset` from Builder will not be used;

To create a change safe instance you can use:

```
$query = \App\Models\User::query();

foreach ($query->getChangeSafeIterator() as $user) {
    // ...
}
```

Mixins
======

[](#mixins)

`\Illuminate\Database\Eloquent\Builder`
---------------------------------------

[](#illuminatedatabaseeloquentbuilder)

NameDescription`orderByKey(string $direction = 'asc')`Add an `ORDER BY primary_key` clause to the query.`orderByKeyDesc()`Alias of `orderByKey('desc')``getChunkedIterator()`Return [`ChunkedIterator`](./src/Iterators/ChunkedIterator.php) instance.`getChangeSafeIteratorIterator()`Return [`ChunkedChangeSafeIterator`](./src/Iterators/ChunkedChangeSafeIterator.php) instance.Upgrading
=========

[](#upgrading)

Please follow [Upgrade Guide](UPGRADE.md).

Contributing
============

[](#contributing)

Please use the [main repository](https://github.com/LastDragon-ru/php-packages) to [report issues](https://github.com/LastDragon-ru/php-packages/issues), send [pull requests](https://github.com/LastDragon-ru/php-packages/pulls), or [ask questions](https://github.com/LastDragon-ru/php-packages/discussions).

###  Health Score

59

—

FairBetter than 99% of packages

Maintenance87

Actively maintained with recent releases

Popularity33

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity86

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~23 days

Recently: every ~53 days

Total

83

Last Release

70d ago

Major Versions

6.4.2 → 7.0.02024-11-17

7.2.0 → 8.0.02025-04-03

8.1.0 → 9.0.02025-04-08

8.x-dev → 9.1.02025-04-10

9.3.1 → 10.0.02026-01-17

PHP version history (8 changes)0.1.0PHP &gt;=7.4.0

0.4.0PHP &gt;=8.0.0

0.12.0PHP ^8.0.0

2.0.0PHP ^8.0|^8.1|^8.2

5.0.0-beta.0PHP ^8.1|^8.2

5.0.0PHP ^8.1|^8.2|^8.3

7.0.0PHP ^8.2|^8.3

8.0.0PHP ^8.3|^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/cd8f9191d64064a1102702bb23c04d6d1b995db2ec0b08d1a59ead018a9476d0?d=identicon)[LastDragon](/maintainers/LastDragon)

---

Top Contributors

[![LastDragon-ru](https://avatars.githubusercontent.com/u/1329824?v=4)](https://github.com/LastDragon-ru "LastDragon-ru (404 commits)")

---

Tags

eloquentlara-asplaravellaravel-packagephplaraveleloquentlaravel-packagelaravel-eloquent

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lastdragon-ru-lara-asp-eloquent/health.svg)

```
[![Health](https://phpackages.com/badges/lastdragon-ru-lara-asp-eloquent/health.svg)](https://phpackages.com/packages/lastdragon-ru-lara-asp-eloquent)
```

###  Alternatives

[spiritix/lada-cache

A Redis based, automated and scalable database caching layer for Laravel

591444.8k2](/packages/spiritix-lada-cache)[ymigval/laravel-model-cache

Laravel package for caching Eloquent model queries

7642.2k3](/packages/ymigval-laravel-model-cache)[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k302.7k1](/packages/cybercog-laravel-love)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)[io238/laravel-iso-countries

Ready-to-use Laravel models and relations for country (ISO 3166), language (ISO 639-1), and currency (ISO 4217) information with multi-language support.

5462.3k](/packages/io238-laravel-iso-countries)[sebastiaanluca/laravel-boolean-dates

Automatically convert Eloquent model boolean attributes to dates (and back).

40111.7k1](/packages/sebastiaanluca-laravel-boolean-dates)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
