How to display content if data is empty in laravel?

Member

by addison , in category: PHP Frameworks , 10 months ago

How to display content if data is empty in laravel?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by brandy , 10 months ago

@addison 

You can use the @empty directive in Laravel Blade to display content if data is empty. Here's an example of how you can use it:

1
2
3
4
5
@if($data->isEmpty())
    <p>No data available.</p>
@else
    <p>Data is available.</p>
@endif


In this example, the isEmpty() method is used to check if the data is empty. If the data is empty, it will display "No data available." Otherwise, it will display "Data is available."

Related Threads:

What is the best way to empty the content on an iframe?
How to display data from 2 tables in laravel?
How to display content of a .json file using discord.js?
How to provide empty values for chart.js data?
How to check if variable is empty in laravel?
How to return empty json as {} in laravel?