How to display 0 but not empty string values or null in Laravel
Categorized as Laravel
There is a beautiful filled()
method in Laravel so that you can avoid unnecessary outputs in your rendering blade-templates. Here is the example:
@if (filled($product->fat))
<tr>
<td>Fat</td>
<td>{{ $product->fat }}</td>
</tr>
@endif
Quantity per serving | |
Energy | 1438 kJ / 338 kcal |
Protein | 0 |
Fat | 0 |
Carbohydrate | 85 |
See the official documentation.
Thnx to Daniel Eckermann.