12 Laravel Features That Will Blow Your Mind

Ismat Babirli
3 min readJun 26, 2023
Photo by Nangialai Stoman on Unsplash

Laravel Eloquent is a feature-rich ORM (Object Relational Model) that offers many powerful features not always highlighted in the official Laravel documentation. This article aims to shed light on these hidden gems, providing insights into how they can enhance your Laravel application development.

Expressive Where Syntax

The Expressive Where Syntax allows for more expressive queries when retrieving a particular record. Instead of the usual $product = Product::where('category', 2)->get();, you can make your query more expressive by suffixing the attribute to the where clause itself: $product = Product::whereCategory(2)->get();.

Returning Relations On Model Save

When saving a model, Laravel Eloquent typically only returns the model you are saving. However, if you want to return its related model, you can do so as follows:

public function store(Request $request, $categoryId)
{
$product = new Product();
$product->fill($request->all());
$product->category_id =…

--

--