Serialize Queries allows developer to serialize Query/Eloquent Builder to be used in Laravel Queues.
To install through composer, run the following command from terminal:
composer require "laravie/serialize-queries"
Laravie\SerializesQuery\Eloquent::serialize(
\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Relations\Relation $builder
): array;
The method provide simple interface to serialize Eloquent Query Builder.
use App\Model\User;
use Laravie\SerializesQuery\Eloquent;
$query = User::has('posts')->where('age', '>', 25);
$serializedQuery = Eloquent::serialize($query);
Laravie\SerializesQuery\Eloquent::unserialize(array $payload): \Illuminate\Database\Eloquent\Builder;
The method provide simple interface to unserialize Eloquent Query Builder.
use Laravie\SerializesQuery\Eloquent;
$query = Eloquent::unserialize($serializedQuery);
Laravie\SerializesQuery\Query::serialize(
\Illuminate\Database\Query\Builder $builder
): array;
The method provide simple interface to serialize Fluent Query Builder.
use Illuminate\Support\Facades\DB;
use Laravie\SerializesQuery\Query;
$query = DB::table('users')->where('age', '>', 25);
$serializedQuery = Query::serialize($query);
Laravie\SerializesQuery\Query::unserialize(array $payload): \Illuminate\Database\Query\Builder;
The method provide simple interface to unserialize Eloquent Builder.
use Laravie\SerializesQuery\Query;
$query = Query::unserialize($serializedQuery);