Eloquent Serialize

anourvalar/eloquent-serialize image

Eloquent Serialize stats

Downloads
388.8K
Stars
72
Open Issues
0
Forks
5

View on GitHub →

Laravel Query Builder (Eloquent) serialization

EloquentSerialize: Eloquent Query Serialization

EloquentSerialize is a Laravel package designed to serialize and unserialize Eloquent query builders, making it easier to cache or store complex query logic in a reusable format. This package supports Laravel version 6 and above.

Key Features

  • Serialization of Query Builders: Convert your Eloquent queries into a storable format.
  • Unserialization: Reconstruct an Eloquent query builder from a serialized state.
  • Compatibility: Works with Laravel 6 and newer versions.

Installation

Install the package via Composer:

composer require anourvalar/eloquent-serialize

Usage

Serialize a Query

Convert an Eloquent query into a serialized string:

$package = \EloquentSerialize::serialize(
\App\User::query()
->with('userPhones')
->where('id', '>', '10')
->limit(20)
);

Unserialize a Query

Rebuild the original Eloquent query from a serialized string:

$builder = \EloquentSerialize::unserialize($package);
 
foreach ($builder->get() as $item) {
// Process each item
}

This package is ideal for developers looking to enhance performance by caching complex queries or needing a method to store and retrieve query logic across different parts of an application or between requests.

AnourValar photo

Telegram: @AnourValar

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


Anourvalar Eloquent Serialize Related Articles

Converting Laravel Models to JSON for API Responses image

Converting Laravel Models to JSON for API Responses

Read article
A guide to Laravel's model events image

A guide to Laravel's model events

Read article
Laravel 9.35 Released image

Laravel 9.35 Released

Read article
Tutorial: Build Metabase Maps with Geocodio image

Tutorial: Build Metabase Maps with Geocodio

Read article
Serialization for Eloquent's QueryBuilder image

Serialization for Eloquent's QueryBuilder

Read article
Getting Started with Laravel Model Events image

Getting Started with Laravel Model Events

Read article
Curotec logo

Curotec

World class Laravel experts with GenAI dev skills. LATAM-based, embedded engineers that ship fast, communicate clearly, and elevate your product. No bloat, no BS.

Curotec
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
Celebian logo

Celebian

Celebian is a social media marketing agency specializing in helping their clients go viral on TikTok. Whether you're looking to reach a bigger audience or gain more Tiktok followers, likes, and views, they've got you covered.

Celebian
The Certification of Competence for Laravel logo

The Certification of Competence for Laravel

A community-driven, proctored assessment across 4 levels designed to validate real-world Laravel knowledge, from Junior to mastery-level Artisan. Official Vue.js, Official Nuxt, Angular, React, JS certifications also available.

The Certification of Competence for Laravel
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Honeybadger logo

Honeybadger

Simple developer-focused application monitoring for Laravel. Error tracking, log management, uptime monitoring, status pages, and more!

Honeybadger