From e77a49ed4d12c61398eb1ae3dd29cebe3c0e04f4 Mon Sep 17 00:00:00 2001 From: Paulo Henrique Garcia Date: Thu, 3 Aug 2023 07:27:36 +0200 Subject: [PATCH] Fix constante names on casts and fillable Use case: the field name is `idAdmin`. Before, the generated code was: ``` ... const ID_ADMIN = 'idAdmin'; ... protected $casts = [ self::IDADMIN => 'int', // <- wrong constant ]; ``` After, it is: ``` ... protected $casts = [ self::ID_ADMIN => 'int' ]; ``` --- src/Coders/Model/Model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Coders/Model/Model.php b/src/Coders/Model/Model.php index cedc834..0b0fd95 100644 --- a/src/Coders/Model/Model.php +++ b/src/Coders/Model/Model.php @@ -254,7 +254,7 @@ protected function parseColumn(Fluent $column) // TODO: Check type cast is OK $cast = $column->type; - $propertyName = $this->usesPropertyConstants() ? 'self::'.strtoupper($column->name) : $column->name; + $propertyName = $this->usesPropertyConstants() ? 'self::'.strtoupper(Str::snake($column->name)) : $column->name; // Due to some casting problems when converting null to a Carbon instance, // we are going to treat Soft Deletes field as string.