© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•6mo ago•
3 replies
Harvey

Eager loaded relationship not updating after component action called

I have an action to upload a specific document, in v3 after it was called, my custom entry could use that newly created document via
$model->documents
$model->documents
but in v4 it does not update.

It's like in v3 the whole model would be refreshed including eager loaded relations, but now the relations are cached.

I don't want to call
$model->documents()->get()
$model->documents()->get()
because that's going to be a lot of extra database queries (I have quite a few fields), but I need the info to be fresh when an action is run to update the state of the field.

I can confirm if I unset the relation it works. But what I would ideally want is for the whole claim to be fetched when the livewire request comes in and then I can use the eager loaded relation throught my infolist schema.

Any ideas as to how I could combat this?

TextEntry:
TextEntry::make("some_field")
  ->state(function (Model $model) {
      return $model->documents->ofType($type)->count() > 3 ? 'foo' : 'bar';
  }),
TextEntry::make("some_field")
  ->state(function (Model $model) {
      return $model->documents->ofType($type)->count() > 3 ? 'foo' : 'bar';
  }),
Solution
Fixed by calling
$model->refresh();
$model->refresh();
after my action is completed. I guess in v3 the caching was more lax, but in v4 it does not refresh the relations etc so you have to do that yourself.
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Eager loaded relationship based on table filter
FilamentFFilament / ❓┊help
3y ago
Eager Loaded Pivot not working
FilamentFFilament / ❓┊help
3y ago
RepeatableEntry not updating after updating Relationship
FilamentFFilament / ❓┊help
4mo ago
Eager loaded relationships filter
FilamentFFilament / ❓┊help
2y ago