Support the ongoing development of →
Blade Eloquent Laravel
Last updated by @ajax30 4 months ago.

First of all define the below relationship in your Comment model.

public function replies()
      return $this->hasMany(Comment::class, 'parent_id', 'id')->with('replies');

After that you can fetch any comment with it's nested replies like this:

Last updated 3 months ago.

Sign in to participate in this thread!

Full Stack Europe

Your banner here too?

Razvan ajax30 Joined 2 Oct 2021


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2023 - All rights reserved.