© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
2 replies
Mnemonic

Repeaters and eager loading relationships

I'm chasing down an issue with some n+1 queries that I'm having trouble getting to eager load properly, and I think it's due to the repeater causing the relationship to be fetched for each item. I'm having trouble figured out how to combine these queries into one. I've tried adding eager loading where I can:

Repeater::make('departments')
    ->relationship('departments', modifyQueryUsing: function(Builder $query) {
        return $query->with([
            'shifts' => [
                'call',
                'user'
            ]
        ]);
Repeater::make('departments')
    ->relationship('departments', modifyQueryUsing: function(Builder $query) {
        return $query->with([
            'shifts' => [
                'call',
                'user'
            ]
        ]);

and
TableRepeater::make('shift')
    ->relationship('shifts', modifyQueryUsing: function (Builder $query) {
        return $query->with(['user', 'call']);
    })
TableRepeater::make('shift')
    ->relationship('shifts', modifyQueryUsing: function (Builder $query) {
        return $query->with(['user', 'call']);
    })


but I'm seeing a zillion repeated queries... I feel like I need to do this at some higher level, but I'm not seeing where that level might be.
image.png
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Eager loading relationships in table
FilamentFFilament / ❓┊help
2y ago
Eager loading relationships in table
FilamentFFilament / ❓┊help
3y ago
Eager loaded relationships filter
FilamentFFilament / ❓┊help
2y ago
Add eager loading
FilamentFFilament / ❓┊help
3y ago