Skip to content

Commit c6a9a83

Browse files
committed
add of to MoneyCast
1 parent 6c64265 commit c6a9a83

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class Invoice extends Model {
9393
protected function casts(): array
9494
{
9595
return [
96-
'amount' => MoneyCast::class . ':currency'
96+
'amount' => MoneyCast::of('currency')
9797
];
9898
}
9999
}
@@ -117,8 +117,8 @@ class Invoice extends Model {
117117
protected function casts(): array
118118
{
119119
return [
120-
'cost' => MoneyCast::class . ':EUR',
121-
'price' => MoneyCast::class . ':USD'
120+
'cost' => MoneyCast::of('EUR'),
121+
'price' => MoneyCast::of('USD')
122122
];
123123
}
124124
}

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
"nunomaduro/collision": "^8.1.1||^7.10.0",
2828
"larastan/larastan": "^3.0",
2929
"orchestra/testbench": "^8.22.0||^9.0.0||^10.0.0",
30-
"pestphp/pest": "^3.0",
31-
"pestphp/pest-plugin-arch": "^3.0",
32-
"pestphp/pest-plugin-laravel": "^3.0",
30+
"pestphp/pest": "^3.0||^4.0",
31+
"pestphp/pest-plugin-arch": "^3.0||^4.0",
32+
"pestphp/pest-plugin-laravel": "^3.0||^4.0",
3333
"phpstan/extension-installer": "^1.3||^2.0",
3434
"phpstan/phpstan-deprecation-rules": "^1.1||^2.0",
3535
"phpstan/phpstan-phpunit": "^1.3||^2.0"

src/MoneyCast.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ public function __construct(
2929
// No initialization required
3030
}
3131

32+
public static function of(string $currencyOrAttribute): string
33+
{
34+
return static::class.':'.$currencyOrAttribute;
35+
}
36+
3237
/**
3338
* @param array<string, mixed> $attributes The model's attributes.
3439
*/

0 commit comments

Comments
 (0)