Skip to content

Commit 1a130a5

Browse files
authored
Merge pull request #76 from NotFoundNL/develop
fix: Error when opening table in CMS editor (#75)
2 parents 47dd01e + f6b60d0 commit 1a130a5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Http/Controllers/CmsEditor/CmsEditorTableController.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,20 @@ private function checkColumn(string $table, object $field): string
289289
$fieldClass = new $className(new stdClass());
290290

291291
if (Schema::hasColumn($table, $field->internal)) {
292-
return $fieldClass->checkColumnType(DB::getDoctrineColumn(set_database_prefix($table), $field->internal)->getType());
292+
return $fieldClass->checkColumnType(DB::getDoctrineColumn($this->setDatabasePrefix($table), $field->internal)->getType());
293293
} else {
294294
return $fieldClass->checkColumnType(null);
295295
}
296296
}
297+
298+
private function setDatabasePrefix(string $tableName)
299+
{
300+
$prefix = config('database.prefix');
301+
$tableName = str_replace('[][]', $prefix, $tableName);
302+
if (strpos($tableName, $prefix) !== 0) {
303+
$tableName = $prefix.$tableName;
304+
}
305+
306+
return $tableName;
307+
}
297308
}

0 commit comments

Comments
 (0)