How can I create a virtual column with a name field from another table
I need to create a virtual column (or something similar) that concatenates the name of the product (products table) with the color of the product variant (product_variants table). The virtual column would be in the variant table. Is there any way to do it?
8 Replies
How can I do it with a Laravel 9 accesor? I try but it gives me an error. this is my code
Forms\Components\Select::make('product_variant_id')
->label('Producto')
->required()
->searchable()
->options(ProductVariant::take(20)->pluck('full_name_product', 'id'))
->required()
->columnSpan(3),
I'm kind of doing the same thing. I think your options()-call is wrong. Try this:
Thank you! but it always worked for me like this. I have discovered that without the get(), it does not work for me, now it does: ->options(ProductVariant::get()->pluck('full_name', 'id'))
That's cause ->get gives you a Collection, ->pluck on a Collection gives you an array. ->options expects either an array or a closure.
is basically the same as
Ahh ok, I undertand, thank you so much!!
Try playing arround with some of those anonymous functions. Filament can do some pretty funky stuff with those. π See where you can pass a Closure and go for it.
hahaha, I'll listen to you, thank you very much once again π
be my guest. π I'm just startin to get the ropes of filament myself tho. π