F
Filament11mo ago
Wim

Conditionally display Form TextInput

I have the following text input:
Forms\Components\TextInput::make('vouchers.code')
->label('Voucher')
Forms\Components\TextInput::make('vouchers.code')
->label('Voucher')
It can be that there is no voucher code and then I prefer not to show the Text Input. If there is a voucher code, I want to show the Text Input. Note: not sure if relevant but I'm using this inside the action method of a table. How can this be achieved?
2 Replies
Keika
Keika11mo ago
How would you progamatically know if there is a voucher?
Wim
WimOP11mo ago
There is a relation between model Product and model Voucher. I could use $product->vouchers. When there is no voucher, the database would indicate a null value. I could do it as follows: $product->vouchers->first() != null But there might be other ways as well (e.g. scopes)
Want results from more Discord servers?
Add your server