DEV Community

Morcos Gad
Morcos Gad

Posted on • Edited on

New Things Added - Laravel 9.16 Released

Let's get started quickly I found new things in Laravel 9.16 Released I wanted to share with you.

method that simplifies cases where you have to repeat code used to both filter with whereHas and select the same record via with()

CollectionModel::whereHas('products', function ($query) {
    $query->where('enabled', true)->where('sale', true);
})->with(['products' => function ($query) {
    $query->where('enabled', true)->where('sale', true);
});
Enter fullscreen mode Exit fullscreen mode

Using the withWhereHas method, you can simplify your code around this use case

CollectionModel::withWhereHas('products', fn ($query) => $query->where('enabled', true)->where('sale', true));
Enter fullscreen mode Exit fullscreen mode

I hope you enjoyed with me and to learn more about this release visit the sources and search more. I adore you who search for everything new.
Source :- https://laravel-news.com/laravel-9-16-0
Source :- https://www.youtube.com/watch?v=ZEDUihpRQMM

Top comments (0)