]> _ Git - cubist_cms-back.git/commitdiff
#2810
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 5 Jun 2019 15:50:19 +0000 (17:50 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 5 Jun 2019 15:50:19 +0000 (17:50 +0200)
src/app/Magic/Controllers/CubistMagicControllerTrait.php
src/app/Magic/Models/CubistMagicAbstractModel.php

index 636975d71b4d19b1065df80a5637049e833bd712..ede1b0c25419ddda43e2dcc36e48f0205224ab0e 100644 (file)
@@ -17,7 +17,6 @@ trait CubistMagicControllerTrait
         if (!$this->_plural) {
             $this->_plural = $this->_singular . 's';
         }
-
         if ($this->_clonable) {
             $this->crud->allowAccess('clone');
         }
index 97fe1f747246761fbee471f2deebb39f83c66a56..62fcd96601f019fada35b8b0a453357b6855f153 100644 (file)
@@ -305,7 +305,7 @@ class CubistMagicAbstractModel extends Model
     {
         foreach ($this->_relationships as $relationship) {
             /** @var $relationship Field */
-            if ($method == $relationship->getAttribute('name')) {
+            if ($method == $relationship->getAttribute('entity')) {
                 return $this->relationship($relationship);
             }
         }
@@ -323,7 +323,7 @@ class CubistMagicAbstractModel extends Model
             case 'belongsTo':
                 return $this->belongsTo($field->getAttribute('model'), $field->getAttribute('name'));
             case 'belongsToMany':
-                return $this->belongsToMany($field->getAttribute('model'), $this->getRelationShipTable($field))->withPivot([$this->getForeignKey(), self::_toModel($field->getAttribute('model'))->getForeignKey()]);
+                return $this->belongsToMany($field->getAttribute('model'), $this->getRelationShipTable($field));
         }
     }