From db46e29c9b3847770f8d79db0be3b5f98bcdff46 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 12 Jun 2019 15:16:15 +0200 Subject: [PATCH] #2810 --- src/app/Magic/Fields/Model.php | 4 ++-- src/app/Magic/Fields/SelectFromArray.php | 2 +- src/app/Magic/Fields/SelectFromModelMultiple.php | 1 + src/app/Magic/Models/CubistMagicAbstractModel.php | 5 +++++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/app/Magic/Fields/Model.php b/src/app/Magic/Fields/Model.php index 11d8774..f9c01da 100644 --- a/src/app/Magic/Fields/Model.php +++ b/src/app/Magic/Fields/Model.php @@ -17,7 +17,7 @@ class Model extends Field public function getDefaultAttributes() { - return array_merge(parent::getDefaultAttributes(), ['attribute' => 'name', 'allow_null' => false, 'allow_multiples' => $this->_multiple]); + return array_merge(parent::getDefaultAttributes(), ['attribute' => 'name', 'allows_null' => false, 'allows_multiple' => $this->_multiple]); } protected function _getOptions() @@ -29,7 +29,7 @@ class Model extends Field $name = $this->getAttribute('attribute'); foreach ($items as $item) { - $options[$item->getPrimaryKey()] = $item->{$name}; + $options[$item->{$item->getPrimaryKey()}] = $item->{$name}; } return $options; } diff --git a/src/app/Magic/Fields/SelectFromArray.php b/src/app/Magic/Fields/SelectFromArray.php index 65b08ad..af51d80 100644 --- a/src/app/Magic/Fields/SelectFromArray.php +++ b/src/app/Magic/Fields/SelectFromArray.php @@ -13,7 +13,7 @@ class SelectFromArray extends Field public function getDefaultAttributes() { - return array_merge(parent::getDefaultAttributes(), ['options' => [], 'allow_null' => true, 'allow_multiples' => $this->_multiple]); + return array_merge(parent::getDefaultAttributes(), ['options' => [], 'allows_null' => true, 'allows_multiple' => $this->_multiple]); } public function getColumnData() diff --git a/src/app/Magic/Fields/SelectFromModelMultiple.php b/src/app/Magic/Fields/SelectFromModelMultiple.php index 7187d09..378f606 100644 --- a/src/app/Magic/Fields/SelectFromModelMultiple.php +++ b/src/app/Magic/Fields/SelectFromModelMultiple.php @@ -7,4 +7,5 @@ namespace Cubist\Backpack\app\Magic\Fields; class SelectFromModelMultiple extends SelectFromModel { protected $_multiple = true; + protected $_cast = 'array'; } diff --git a/src/app/Magic/Models/CubistMagicAbstractModel.php b/src/app/Magic/Models/CubistMagicAbstractModel.php index 14bd0bb..7d9d151 100644 --- a/src/app/Magic/Models/CubistMagicAbstractModel.php +++ b/src/app/Magic/Models/CubistMagicAbstractModel.php @@ -443,4 +443,9 @@ class CubistMagicAbstractModel extends Model implements HasMedia ->sharpen(10) ->optimize(); } + + public function getIdValue() + { + return $this->{$this->getPrimaryKey()}; + } } -- 2.39.5