HasMany relationship loads all the data while attaching #3216
Unanswered
sonalmahajan01
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a model Organization with relationship :
public function users() { return $this->hasMany(User::class); }
In Nova, its used as:
HasMany::make('departments')
But when we click on Attach Users, it loads all the Organizations in the Select dropdown though there is no need to load all and just the one we are updating.
The query that gets sent out is:
http://localhost:8095/nova-api/departments/associatable/organization?current=1&first=false&search=&withTrashed=false&viaResource=organizations&viaResourceId=1&viaRelationship=departments
. I checked if somehow i can manipulate the value of first=true, it loads only the correct organization, but could not find a way to override this.As there are many organizations in our db, it takes a long time to load the data and screen just freezes. Is there any way, to turn off loading all the organizations in Has Many relationship?
Beta Was this translation helpful? Give feedback.
All reactions