I’m having a problem here in solving a problem, I have a popover that takes the information from the database is possible if there is nothing posted in the “note” field, does it change the color of the button?
<td><a tabindex="0" class="btn btn-lg btn-danger" role="button" data-toggle="popover" data-trigger="focus" title="Observações" data-placement="right" data-content="{{$item->observacao}}">Obs</a> </td>
Advertisement
Answer
In order to achieve this, you could user PHP’s ternary operators to check if record has note
property, like this:
class="btn btn-lg btn-{{$item->note ? 'color when item has note" : 'color when item doesnt have note'}}"
The ?
operator here acts like if-else
condition. First expression will be executed if the condition is satisfied, and the second if conidition is not satisfied. Let me know if you need any additional help with this.