Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Wakanda's avatar
Level 10

Access a model method collection from a Nova Resource, and display the result collection as a table in Laravel Nova

Hi devs,

I have a method in my model that represents a filtered collection of a sibling tree.

public function siblings()
    {
        if (is_null($this->father_id) && is_null($this->mother_id)) {
            return collect([]);
        }

        return User::where('id', '!=', $this->id)
            ->where(function ($query) {
                if (!is_null($this->father_id)) {
                    $query->where('father_id', $this->father_id);
                }

                if (!is_null($this->mother_id)) {
                    $query->orWhere('mother_id', $this->mother_id);
                }
            })
            ->orderBy('date_of_birth')->get();
    }

I want to access the above model method siblings() in the Nova User show view method as a collection in a table.

0 likes
0 replies

Please or to participate in this conversation.