Skip to content

Commit 50c3412

Browse files
committed
Update
- Fixed: float precission when not set on options. - Added: new math service class.
1 parent ddd5474 commit 50c3412

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

app/Casts/FloatConvertCasting.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class FloatConvertCasting implements CastsAttributes
1717
*/
1818
public function get($model, string $key, $value, array $attributes)
1919
{
20-
return ns()->currency->getRaw( $value );
20+
return ns()->math->set( $value )->toFloat();
2121
}
2222

2323
/**

app/Providers/AppServiceProvider.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use App\Services\DemoService;
1717
use App\Services\ExpenseService;
1818
use App\Services\Helper;
19+
use App\Services\MathService;
1920
use App\Services\MediaService;
2021
use App\Services\MenuService;
2122
use App\Services\NotificationService;
@@ -129,7 +130,8 @@ public function register()
129130
app()->make( OrdersService::class ),
130131
app()->make( NotificationService::class ),
131132
app()->make( ProcurementService::class ),
132-
app()->make( Options::class )
133+
app()->make( Options::class ),
134+
app()->make( MathService::class )
133135
);
134136
});
135137

app/Services/CoreService.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public function __construct(
2929
public OrdersService $order,
3030
public NotificationService $notification,
3131
public ProcurementService $procurement,
32-
public Options $option
32+
public Options $option,
33+
public MathService $math
3334
) {
3435
// ...
3536
}

app/Services/MathService.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
namespace App\Services;
3+
4+
use Brick\Math\BigNumber;
5+
6+
class MathService
7+
{
8+
public function set( $value )
9+
{
10+
return BigNumber::of( $value );
11+
}
12+
}

0 commit comments

Comments
 (0)