When supplying the currency() or the locale() function on the HasMoneyAttributes trait it throws an error because the supplied Closure is directly given to the Currency constructor which only takes a string argument.
Solution
Using the $this->evaluate() function to first evaluate the result of the closure and then give it to the constructor. In the case of locale() the evaluation is necessary because protected string $locale is type-hinted to be a string which would also throw an error.
Convention
Every trait in Laravel, Filament that starts with Has is pascal case. Since that wasn't the case here i changed it as well.
Problem
When supplying the
currency()
or thelocale()
function on theHasMoneyAttributes
trait it throws an error because the suppliedClosure
is directly given to theCurrency
constructor which only takes a string argument.Solution
Using the
$this->evaluate()
function to first evaluate the result of the closure and then give it to the constructor. In the case oflocale()
the evaluation is necessary becauseprotected string $locale
is type-hinted to be a string which would also throw an error.Convention
Every trait in Laravel, Filament that starts with
Has
is pascal case. Since that wasn't the case here i changed it as well.