1
0
Fork 0
mirror of https://github.com/archtechx/money.git synced 2025-12-12 11:24:03 +00:00

cents() method

This commit is contained in:
Samuel Štancl 2021-11-28 18:38:54 +01:00
parent 8dc5287868
commit f5bf658155
2 changed files with 24 additions and 0 deletions

View file

@ -249,6 +249,15 @@ final class Money implements JsonSerializable, Arrayable, Wireable
return $this->rounded()->value() - $this->value();
}
/** Get the cents from the decimal value. */
public function cents(): static
{
return static::fromDecimal(
$this->decimal() - floor($this->decimal()),
$this->currency,
);
}
public function toLivewire()
{
return $this->toArray();