anourvalar/eloquent-serialize
Serialize and restore Laravel Eloquent QueryBuilder instances. Save complex queries (with relations, where clauses, limits, etc.) to an array/package and later unserialize back into a builder to run the query again. Supports Laravel 6–12.
Supports: Laravel 6 - Laravel 12
composer require anourvalar/eloquent-serialize
$package = \EloquentSerialize::serialize(
\App\User::query()
->with('userPhones')
->where('id', '>', '10')
->limit(20)
);
$builder = \EloquentSerialize::unserialize($package);
foreach ($builder->get() as $item) {
// ...
}
How can I help you explore Laravel packages today?