ancestorsWithSelf() queries database for each ancestor
Having a similar issue to #231.
Using v6.1.1 on laravel/framework v8.26.1
public function getLinkIdsAttribute()
{
return $this->ancestorsWithSelf()->get()->pluck('indextag_id')->implode('.');
}
I end up with hundreds of queries that result from the above code
select * from `subjects` inner join `subject_closure` on `ancestor` = `subjects`.`id` where `descendant` = 61125 and `depth` = 0
Is there a way to eager load the ancestors or a better way of plucking these ids?
Thank you for your time and consideration. Your package is fantastic.
@mefenlon I have to say sorry for not working on the package for so long. I understand that it feels like the package is abandoned. But I just need to find a passion again to work on it since I haven't worked with Laravel itself for quite a while.
I understand that you're likely to miss the context already (or probably got rid of the package at all). But still, have you tried something like
public function getLinkIdsAttribute()
{
return $this->ancestorsWithSelf()->with('parent')->get()->pluck('indextag_id')->implode('.');
}