laravie / serialize-queries
Serializable Laravel Query Builder
Installs: 4 815 200
Dependents: 5
Suggesters: 0
Security: 0
Stars: 67
Watchers: 4
Forks: 5
Open Issues: 0
Requires
- php: ^8.1
- illuminate/database: ^10.48.23 || ^11.31
- illuminate/queue: ^10.48.23 || ^11.31
- laravel/serializable-closure: ^1.3 || ^2.0
Requires (Dev)
- laravel/pint: ^1.17
- orchestra/testbench: ^8.28 || ^9.6
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^10.1 || ^11.0
README
Serialize Queries allows developer to serialize Query/Eloquent Builder to be used in Laravel Queues.
Installation
To install through composer, run the following command from terminal:
composer require "laravie/serialize-queries"
Usages
Eloquent Query Builder
Serialize
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);
Unserialize
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);
Fluent Query Builder
Serialize
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);
Unserialize
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);