From 8c109d9719f0564b3c89686081b6c6362971a538 Mon Sep 17 00:00:00 2001 From: Masroor Ehsan Date: Wed, 8 Jan 2025 20:03:41 +0600 Subject: [PATCH] FIXED - binary csat --- app/Casts/Compressed.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Casts/Compressed.php b/app/Casts/Compressed.php index 859ef9f..1968699 100644 --- a/app/Casts/Compressed.php +++ b/app/Casts/Compressed.php @@ -9,11 +9,21 @@ class Compressed implements CastsAttributes { public function get(Model $model, string $key, mixed $value, array $attributes): mixed { + if (blank($value)) { + return null; + } + + if (is_resource($value)) { + rewind($value); + $value = stream_get_contents($value); + } + // $value = pg_unescape_bytea($value); + return gzinflate($value); } public function set(Model $model, string $key, mixed $value, array $attributes): mixed { - return gzdeflate($value); + return blank($value) ? null : pg_escape_bytea(gzdeflate($value)); } }