MorphTo Relationship didn't load when the data is too many #5864
-
Description:I have users, twitter_user tables, and components tables these three tables have a Morph relationship Relationship Code // Component Model
public function author()
{
return $this->morphTo()->withDefault(function () {
return new TwitterUser([
'name' => 'Anonymous',
'anon' => true,
'slug' => 'anon',
'avatar' => '/svg/anon.svg',
]);
});
}
//------------------------------------------------------------------------
// User Model
public function components()
{
return $this->morphMany(Component::class, 'author');
}
//----------------------------------------------------------------------
// Nova Field
MorphTo::make('author')->types([
User::class,
TwitterUser::class,
])->nullable(),So the issue is when I select the user option from the menu the app crashes after some debugging I found the reason is the user's table has much data over 14k rows. This issue happened in the create and edit pages How can I paginate the relation on the edit page I need just the author that has created the component if I want to update and then load the users with pagination. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
You should use |
Beta Was this translation helpful? Give feedback.

You should use
MorphTo::searchable()for such usage.