Convert model name from PascalCase to snake_case (table name).

This commit is contained in:
KJ 2024-05-12 04:38:45 -04:00
parent f9b2c678f7
commit 27b5ed6015

View File

@ -287,7 +287,14 @@ class Model {
*/ */
public static function className(): string public static function className(): string
{ {
return strtolower(substr(strrchr(get_called_class(), '\\'), 1)); return strtolower(
preg_replace(
'/(?<!^)[A-Z]/', '_$0',
substr(
strrchr(get_called_class(), '\\'), 1
)
)
);
} }
/** /**