Eager load record on Edit Page
Instead of extending
getEloquentQuery
which affects ListRecords page, how can I add eager loading to the CreateRecord only?
The same way you can do this for ListRecords using getTableQuery
6 Replies
Why do you want to eager load a single record?
Sorry maybe not the best example... on the EditRecord I want to add eager loading which doesn’t affect the ListRecord
Yes. But if you don't want eager loading on ListRecord, what's the sense of eager loading? There is only one
$record
on the edit page. I don't think there will be any difference in performance.Yes so that it’s cached and not running duplicate queries.
I have a relational database and deep nested form that includes lots of helper hints and lookups.
Find it faster/cleaner to use eager loading to fetch this data from the relations of the record instance, instead of cluttering the page with lots of duplicate eloquent lookups.
Okay, valid point. You can probably overwrite the
mount()
to preload. Don't forget to call parent::mount()
Cheers that’s worked perfectly quick switch to
load
instead of with
. Yeah defiantly wouldn’t’ want to forget the authorization check 🙂
See how it does I might need to run the load before the fillForm is called