From 7815ac0e42e09aba3e0791112ab69c06c2901ecf Mon Sep 17 00:00:00 2001 From: Alex Oroshchuk Date: Thu, 14 Jul 2022 12:00:19 +0100 Subject: [PATCH 1/3] Make string attribute value trimming optional because not all attributes are made equal. --- src/Database/Model.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Database/Model.php b/src/Database/Model.php index 2add8b610..85d7ad274 100644 --- a/src/Database/Model.php +++ b/src/Database/Model.php @@ -49,6 +49,11 @@ class Model extends EloquentModel */ public $duplicateCache = true; + /** + * @var bool Indicates if all model attributes will be trimmed prior to saving. + */ + public $trimAttributes = true; + /** * @var array The array of models booted events. */ @@ -1239,7 +1244,7 @@ public function setAttribute($key, $value) /* * Trim strings */ - if (is_string($value)) { + if ($this->trimAttributes && is_string($value)) { $value = trim($value); } From 563ac19a49ab3bc831c3b476ff48b7d221c43017 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Thu, 14 Jul 2022 22:53:48 -0600 Subject: [PATCH 2/3] Update src/Database/Model.php --- src/Database/Model.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Database/Model.php b/src/Database/Model.php index 85d7ad274..2c22ca46b 100644 --- a/src/Database/Model.php +++ b/src/Database/Model.php @@ -50,9 +50,9 @@ class Model extends EloquentModel public $duplicateCache = true; /** - * @var bool Indicates if all model attributes will be trimmed prior to saving. + * @var bool Indicates if all string model attributes will be trimmed prior to saving. */ - public $trimAttributes = true; + public $trimStringAttributes = true; /** * @var array The array of models booted events. From 16f075964bba8b8aa1a580b40d54df8759f07435 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Thu, 14 Jul 2022 22:54:00 -0600 Subject: [PATCH 3/3] Update src/Database/Model.php --- src/Database/Model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Database/Model.php b/src/Database/Model.php index 2c22ca46b..cd8cd1a24 100644 --- a/src/Database/Model.php +++ b/src/Database/Model.php @@ -1244,7 +1244,7 @@ public function setAttribute($key, $value) /* * Trim strings */ - if ($this->trimAttributes && is_string($value)) { + if ($this->trimStringAttributes && is_string($value)) { $value = trim($value); }