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))
  <td>{{ $product->fat }}</td>
Quantity per serving
Energy1438 kJ / 338 kcal

See the official documentation.

Thnx to Daniel Eckermann.

Leave a reply

Your email address will not be published. Required fields are marked *