Eloquent Serialize
Eloquent Serialize stats
- Downloads
- 388.8K
- Stars
- 72
- Open Issues
- 0
- Forks
- 5
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.