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);
}
class SelectFromModel extends Model
{
protected $_adminType = 'select2';
- protected $_databaseType = 'string';
+ protected $_databaseType = 'text';
protected $_multiple = false;
$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') {
}
}
+ foreach ($this->_fields as $field) {
+ if ($field->getRelationship() == 'belongsToMany') {
+ $field->defineDbColumn($table);
+ }
+ }
+
+ if ($this->timestamps) {
+ $this->_addTimestampsDatabaseColumns($table);
+ }
+
+
return $table;
}
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);
}
}