From: Vincent Vanwaelscappel Date: Mon, 3 Jun 2019 14:20:39 +0000 (+0200) Subject: #2810 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=b61a4914e628b66aea5262b44fddd2d7a1121b71;p=cubist_cms-back.git #2810 --- diff --git a/src/app/Console/Commands/GenerateCommand.php b/src/app/Console/Commands/GenerateCommand.php index fbdde82..d40aa23 100644 --- a/src/app/Console/Commands/GenerateCommand.php +++ b/src/app/Console/Commands/GenerateCommand.php @@ -45,7 +45,7 @@ class GenerateCommand extends CubistCommand mkdir($routesDir, 0777, true); } $stub = file_get_contents(Util::getStubPath() . '/routes.stub'); - $stub = str_replace('_CUSTOM_', implode("\n", $this->_routes), $stub); + $stub = str_replace('_CUSTOM_', implode("\n ", $this->_routes), $stub); file_put_contents($routesDir . '/custom.php', $stub); } diff --git a/src/app/Magic/Fields/SelectFromModel.php b/src/app/Magic/Fields/SelectFromModel.php index 0040e58..e2db27f 100644 --- a/src/app/Magic/Fields/SelectFromModel.php +++ b/src/app/Magic/Fields/SelectFromModel.php @@ -7,7 +7,7 @@ namespace Cubist\Backpack\app\Magic\Fields; class SelectFromModel extends Model { protected $_adminType = 'select2'; - protected $_databaseType = 'string'; + protected $_databaseType = 'text'; protected $_multiple = false; diff --git a/src/app/Magic/Models/CubistMagicAbstractModel.php b/src/app/Magic/Models/CubistMagicAbstractModel.php index 017395c..57a0c47 100644 --- a/src/app/Magic/Models/CubistMagicAbstractModel.php +++ b/src/app/Magic/Models/CubistMagicAbstractModel.php @@ -224,13 +224,6 @@ class CubistMagicAbstractModel extends Model $table->setPrimaryKey([$this->primaryKey], 'pk_' . $this->table); - foreach ($this->_fields as $field) { - $field->defineDbColumn($table); - } - - if ($this->timestamps) { - $this->_addTimestampsDatabaseColumns($table); - } foreach ($this->_relationships as $relationship) { if ($relationship->getRelationship() === 'belongsToMany') { @@ -246,6 +239,17 @@ class CubistMagicAbstractModel extends Model } } + foreach ($this->_fields as $field) { + if ($field->getRelationship() == 'belongsToMany') { + $field->defineDbColumn($table); + } + } + + if ($this->timestamps) { + $this->_addTimestampsDatabaseColumns($table); + } + + return $table; } @@ -269,8 +273,8 @@ class CubistMagicAbstractModel extends Model public function __call($method, $parameters) { foreach ($this->_relationships as $relationship) { - /** @var $relationship ['field'] Field */ - if ($method == $relationship['field']->getAttrbute('name')) { + /** @var $relationship Field */ + if ($method == $relationship->getAttrbute('name')) { return $this->relationship($relationship); } }