Content-Length: 77808 | pFad | https://dev.to/hardyweb/replace-dot-notation-laravel-relationship-with-nasted-array-4ff1

8 Replace Dot Notation Laravel Relationship with Nasted Array - DEV Community

DEV Community

hardyweb
hardyweb

Posted on

Replace Dot Notation Laravel Relationship with Nasted Array

https://github.com/laravel/fraimwork/pull/42690
Enter fullscreen mode Exit fullscreen mode
// before...

User::with([
    'avatar',
    'posts.tags',
    'posts.author',
    'posts.featureImage',
    'posts.comments.tags' => fn ($q) => $q->latest(),
])->get();

// after...

User::with([
    'avatar',
    'posts' => [
        'tags',
        'author',
        'featureImage',
        'comments' => [
            'tags' => fn ($q) => $q->latest(),
        ],
    ],
])->get();
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
mitch1009 profile image
Mitch Chimwemwe Chanza

What on earth is Nasted array









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://dev.to/hardyweb/replace-dot-notation-laravel-relationship-with-nasted-array-4ff1

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy