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
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
PhpStorm logo

PhpStorm

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

PhpStorm
Tighten logo

Tighten

We help companies turn great ideas into amazing apps, products, and services.

Tighten
LoadForge logo

LoadForge

Scalable load testing for web apps & APIs. Simulate real-world traffic and identify breaking points and performance limits with powerful, scalable load tests designed for Laravel.

LoadForge
Securing Laravel logo

Securing Laravel

The essential security resource for Laravel devs, covering everything you need to keep your apps secure. Sign up to receive weekly security tips and monthly in depth articles, diving deep into security concepts you need to know!

Securing Laravel
Blastup logo

Blastup

Blastup provides social media enhancement services including buying Instagram likes, followers, and views, with features like instant delivery and a variety of packages to suit different needs.

Blastup