...\Tables\Columns\Concerns\{closure}(): Return value must be of type ?string, Money\Money return

I made a product model with a price that has been cast by Money Money package. In the front all works fine. I now want a adminpanel but when i created the resource with the --generate option. It created the form but got following error: Filament\Tables\Columns\TextColumn::Filament\Tables\Columns\Concerns{closure}(): Return value must be of type ?string, Money\Money returned I use the Money php package and it returns a money object. How can i show it in the filament table? Thanks in advance!
4 Replies
toeknee
toeknee2mo ago
IT's a column and a column cannot parse Money\Money so convert it to a string and return that.
Sens420
Sens4202mo ago
That I already figured out. But maybe you can hint me how to do that? But i need the object return also for frontend.
toeknee
toeknee2mo ago
I'd need to see your code...
Sens420
Sens4202mo ago
Nevermind, I found a solution on LaravelDaily. public function get(Model $model, string $key, mixed $value, array $attributes): float { // Transform the integer stored in the database into a float. return round(floatval($value) / 100, precision: 2); } Thanks!