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)); } }