Elasticquent icon indicating copy to clipboard operation
Elasticquent copied to clipboard

How to set eloquent relation data?

Open nahid opened this issue 8 years ago • 2 comments

Suppose I have Model Post and every post has many Comment. So how to set index for this Post with its Comments?

nahid avatar Jan 15 '17 08:01 nahid

You could bind to a model event such as updated.

Then iterate through the relations:

$post->comments->each(function ($comment) {
    $comment->updateIndex();
});

I would do this asynchronously through a queue.

andrewmclagan avatar Jan 30 '17 07:01 andrewmclagan

Please help me i m also facing this issue . how to index relationship. i have company basic info table then address table and phone no table. So how can index company relationship.

mazharrehman avatar Jan 21 '19 00:01 mazharrehman