diff --git a/src/Resolvers/DecimalResolver.php b/src/Resolvers/DecimalResolver.php index 90655d5..1a84d47 100644 --- a/src/Resolvers/DecimalResolver.php +++ b/src/Resolvers/DecimalResolver.php @@ -49,6 +49,10 @@ public function nova(): ?string public function cast(): ?string { - return 'decimal:'.Bracket::of($this->column->bracket)->escape(); + if (empty($this->column->bracket)) { + return null; + } + + return 'decimal:'.trim(preg_replace('/.+,/', '', $this->column->bracket)); } } diff --git a/tests/Unit/Resolvers/DecimalResolverTest.php b/tests/Unit/Resolvers/DecimalResolverTest.php index 5e49e76..e0fba14 100644 --- a/tests/Unit/Resolvers/DecimalResolverTest.php +++ b/tests/Unit/Resolvers/DecimalResolverTest.php @@ -54,6 +54,15 @@ public function test_fake_method_can_working_well_with_bracket(): void $this->assertEquals('\''.$resolver->field.'\' => fake()->randomFloat(2, 0, 999999),', $resolver->fake()); } + public function test_cast_can_working_well_with_bracket(): void + { + $this->column->bracket = '8, 2'; + + $resolver = new DecimalResolver($this->column); + + $this->assertEquals('decimal:2', $resolver->cast()); + } + public function test_migration_method_can_working_well(): void { $resolver = new DecimalResolver($this->column);