From b779df0174454fea203c10d7582465f9ddaf22fb Mon Sep 17 00:00:00 2001 From: Ben Thomson Date: Sun, 9 Aug 2020 19:30:53 +0800 Subject: [PATCH] Override isGuarded method changes from upstream https://github.com/laravel/framework/commit/897d107775737a958dbd0b2f3ea37877c7526371 introduced a change to the attribute guard that prevents fields that do not exist in the database from being filled if guarded properties are specified. This breaks certain functionality (eg. the File model) which has fields that don't exist in the database but are handled separately, such as with a beforeSave event. --- src/Database/Concerns/GuardsAttributes.php | 26 ++++++++++++++++++++++ src/Database/Model.php | 3 +-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 src/Database/Concerns/GuardsAttributes.php diff --git a/src/Database/Concerns/GuardsAttributes.php b/src/Database/Concerns/GuardsAttributes.php new file mode 100644 index 000000000..438085b96 --- /dev/null +++ b/src/Database/Concerns/GuardsAttributes.php @@ -0,0 +1,26 @@ +getGuarded())) { + return false; + } + + return $this->getGuarded() == ['*'] || + ! empty(preg_grep('/^'.preg_quote($key).'$/i', $this->getGuarded())); + } +} diff --git a/src/Database/Model.php b/src/Database/Model.php index 164171b90..1c6b70acd 100644 --- a/src/Database/Model.php +++ b/src/Database/Model.php @@ -1,7 +1,5 @@