Skip to content

ancestorsWithSelf() queries database for each ancestor  #245

@mefenlon

Description

@mefenlon

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions