Conditionally display Form TextInput
I have the following text input:
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
How would you progamatically know if there is a voucher?
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)