Skip to content

Commit e82fdba

Browse files
committed
Fix a null error
1 parent 0ce1cea commit e82fdba

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Resolvers/DecimalResolver.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ public function nova(): ?string
4949

5050
public function cast(): ?string
5151
{
52-
return 'decimal:'.Bracket::of($this->column->bracket)->escape();
52+
if (empty($this->column->bracket)) {
53+
return null;
54+
}
55+
56+
return 'decimal:'.trim(preg_replace('/.+,/', '', $this->column->bracket));
5357
}
5458
}

tests/Unit/Resolvers/DecimalResolverTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ public function test_fake_method_can_working_well_with_bracket(): void
5454
$this->assertEquals('\''.$resolver->field.'\' => fake()->randomFloat(2, 0, 999999),', $resolver->fake());
5555
}
5656

57+
public function test_cast_can_working_well_with_bracket(): void
58+
{
59+
$this->column->bracket = '8, 2';
60+
61+
$resolver = new DecimalResolver($this->column);
62+
63+
$this->assertEquals('decimal:2', $resolver->cast());
64+
}
65+
5766
public function test_migration_method_can_working_well(): void
5867
{
5968
$resolver = new DecimalResolver($this->column);

0 commit comments

Comments
 (0)