Skip to content

Commit a929d0a

Browse files
Fix table name generation for weird cases
1 parent ed4baef commit a929d0a

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/Models/BaseModel.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ public static function table(): string
7878
$className = (new \ReflectionClass(static::class))->getShortName();
7979

8080
// Convert PascalCase to snake_case (no pluralization)
81-
$tableName = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $className));
81+
// Must match ModelScanner::classNameToTableName() to avoid table name mismatches
82+
$tableName = strtolower((string) preg_replace('/([A-Z])/', '_$1', lcfirst($className)));
8283

8384
return $tableName;
8485
}

0 commit comments

Comments
 (0)