$attributes */ public function get(Model $model, string $key, mixed $value, array $attributes): mixed { return (float) $value; } /** * Prepare the given value for storage in base currency * * @param array $attributes */ public function set(Model $model, string $key, mixed $value, array $attributes): mixed { // for market data and transactions the `currency` attribute is available... // but for dividends and other types, need to make sure `market_data` is loaded if (is_null($model?->currency)) { $model->loadMarketData(); } return Currency::convert( (float) $value, $model?->currency ?? $model->market_data?->currency, config('investbrain.base_currency'), $model?->date ); } }