MrPunyapal
MrPunyapal

Punyapal Shah

Verified

@MrPunyapal

Laravel Artisan, PHP dev, Consultant, Speaker, opensource contributor, Part of @LaravelArtisans , @LaravelAhm , Core @Pinkary , @pestphp , YouTuber.
2K Posts 20K Views
  • No matching results...
  • Searching...

/ 255

New in Laravel 13.21: #[RequestAttribute]

The request attributes bag is perfect for data you've already resolved during the current request.

For example, if middleware has already loaded the current tenant, there's no reason to hit the database again later.

#[RequestAttribute] makes reusing that request-scoped data much cleaner
image

Most Laravel developers know unique().

But did you know Collections also have duplicates()?

One thing that surprised me is how it works.

If a value appears 3 times, it will be returned twice. Every occurrence after the first is considered a duplicate.
image

29

Most Laravel developers know pipe().

Far fewer know about pipeThrough().

Instead of one transformation, you can pass your collection through multiple reusable callables, keeping each step small, focused, and easy to test.

Have you ever used it?
image

31