From 19ab819f7a73eb573db71ef3a4f6c8eb6cbf81dc Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 20 Jan 2022 18:04:00 +0100 Subject: [PATCH] wip #5041 @0.5 --- src/app/Magic/Models/CubistMagicAbstractModel.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/app/Magic/Models/CubistMagicAbstractModel.php b/src/app/Magic/Models/CubistMagicAbstractModel.php index c996869..b5c5ce9 100644 --- a/src/app/Magic/Models/CubistMagicAbstractModel.php +++ b/src/app/Magic/Models/CubistMagicAbstractModel.php @@ -72,6 +72,8 @@ class CubistMagicAbstractModel extends Model implements HasMedia protected $_baseController = CubistMagicController::class; + protected static array $_reservedNames = ['media']; + /** * @var array */ @@ -328,6 +330,13 @@ class CubistMagicAbstractModel extends Model implements HasMedia return $attributes; } + protected function checkForReservedNames($name) + { + if (in_array($name, static::$_reservedNames)) { + throw new \Exception(sprintf('The attribute name %s is reserved', $name)); + } + } + /** * @param string|array $name * @param string $type @@ -340,6 +349,8 @@ class CubistMagicAbstractModel extends Model implements HasMedia { $attributes = self::normalizeAttributes($name, $type, $label, $attributes); + $this->checkForReservedNames($name); + $field = $this->bunchAddField($attributes); $field->setModelInstance($this); $name = $field->getAttribute('name'); -- 2.39.5