]> _ Git - cubist_cms-back.git/commitdiff
#2810
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 5 Jun 2019 17:07:33 +0000 (19:07 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 5 Jun 2019 17:07:33 +0000 (19:07 +0200)
src/app/Magic/Fields/Number.php [new file with mode: 0644]
src/app/Magic/Models/CubistMagicAbstractModel.php

diff --git a/src/app/Magic/Fields/Number.php b/src/app/Magic/Fields/Number.php
new file mode 100644 (file)
index 0000000..88eb342
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+
+
+namespace Cubist\Backpack\app\Magic\Fields;
+
+
+class Number extends Field
+{
+    protected $_adminType = 'number';
+    protected $_databaseType = 'float';
+}
index 62fcd96601f019fada35b8b0a453357b6855f153..715d4efd23ede73e799399c2097bd0f989afa752 100644 (file)
@@ -314,11 +314,19 @@ class CubistMagicAbstractModel extends Model
     }
 
     /**
-     * @param $field Field
+     * @param $field Field|string
      * @return \Illuminate\Database\Eloquent\Relations\BelongsTo|\Illuminate\Database\Eloquent\Relations\BelongsToMany
      */
     public function relationship($field)
     {
+        if (is_string($field)) {
+            foreach ($this->_fields as $f) {
+                if($f->getAttribute('entity')==$field){
+                    $field=$f;
+                    break;
+                }
+            }
+        }
         switch ($field->getRelationship()) {
             case 'belongsTo':
                 return $this->belongsTo($field->getAttribute('model'), $field->getAttribute('name'));