Skip to content

Commit

Permalink
fix hashed cast
Browse files Browse the repository at this point in the history
  • Loading branch information
bastien-phi committed Oct 17, 2023
1 parent 994ce61 commit 44c0002
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Domain/Models/AttributeTypeCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ private function resolveFromCast(Attribute $attribute): string
[$castType, $arguments] = [$arguments ?? 'mixed', null];
}

if ($castType === 'hashed') {
$castType = 'string';
}

switch (Str::lower($castType)) {
case 'int':
case 'integer':
Expand Down
1 change: 1 addition & 0 deletions tests/Fixtures/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class User extends Model
'name' => Uppercase::class,
'nullable_name' => Uppercase::class,
'role' => Role::class,
'password' => 'hashed',
];

public function posts(): HasMany
Expand Down
1 change: 1 addition & 0 deletions tests/expected/User.stub
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class User extends Model
'name' => Uppercase::class,
'nullable_name' => Uppercase::class,
'role' => Role::class,
'password' => 'hashed',
];

public function posts(): HasMany
Expand Down

0 comments on commit 44c0002

Please sign in to comment.