---
title: "5 Hidden Laravel Features That Will Instantly Clean Up Your Code"
url: https://daily.dev/posts/5-hidden-laravel-features-that-will-instantly-clean-up-your-code-8vzvp6nlf
source_url: https://medium.com/@developerawam/5-hidden-laravel-features-that-will-instantly-clean-up-your-code-9d09c01d9313
type: article
source: "Medium"
published: 2025-06-04T15:54:31.034Z
updated: 2025-06-04T15:54:52.558Z
tags: ["webdev", "php", "laravel"]
reading_time: 3
upvotes: 132
comments: 4
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# 5 Hidden Laravel Features That Will Instantly Clean Up Your Code

**[Medium](https://daily.dev/sources/medium_js)** · 3 min read · 132 upvotes · 4 comments

## Summary

Laravel offers several underutilized features that can significantly improve code quality and readability. Key features include @forelse for handling empty collections in Blade templates, when() method for conditional query building, sortByDesc() for collection sorting, isEmpty() for cleaner empty checks, and whereRelation() for simplified relationship filtering in Laravel 9+. These methods replace verbose conditional statements and make code more expressive and maintainable.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://medium.com/@developerawam/5-hidden-laravel-features-that-will-instantly-clean-up-your-code-9d09c01d9313>

## Community discussion

Top comments from developers on daily.dev.

**@hasanalsalamy** · 1 upvotes

> do laravel devs  not know about them ?

**@grafmouse** · 1 upvotes

> Those are not hidden features - they are formally documented.

**@trinhminhnhat** · 0 upvotes

> Nice tips 😊

**@embre** · 0 upvotes

> Amazing!

## Similar posts on daily.dev

- [Don’t just attend KubeCon \+ CloudNativeCon, Merge Forward your experience\!](https://daily.dev/posts/don-t-just-attend-kubecon-cloudnativecon-merge-forward-your-experience--l0rpp73x8) · CNCF · 0 upvotes · 0 comments
- [Announcing H2 2026 KCDs](https://daily.dev/posts/announcing-h2-2026-kcds-m96goajm1) · CNCF · 1 upvotes · 0 comments
- [Two months of Open Community Groups](https://daily.dev/posts/two-months-of-open-community-groups-asf52zhbs) · CNCF · 0 upvotes · 0 comments

---

Tags: [#webdev](https://daily.dev/tags/webdev), [#php](https://daily.dev/tags/php), [#laravel](https://daily.dev/tags/laravel)

[View this post on daily.dev](https://daily.dev/posts/5-hidden-laravel-features-that-will-instantly-clean-up-your-code-8vzvp6nlf)
