https://sebastiandedeyne.com/empty-states-with-css-and-the-only-child-selector https://sebastiandedeyne.com/tags/css https://sebastiandedeyne.com/tags/tailwind https://sebastiandedeyne.com/tags/laravel https://sebastiandedeyne.com/tags/blade When you're rendering a list, I often wrap a loop in an if/else statement to display an empty state when the list is empty.

If you want to reduce nesting and drop the conditional, here's a smart trick with the :only-child selector to display the message when there are no events. @foreach($events as $event) {{ $event->name }} @endforeach

We hide the message, but when it's the only child in the section, we'll display it.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners