问题
I was getting an output like this parent
child 1 ==> level 1
Sub-child 1 ==> level 2
sub-Sub-child ==> level 3
Sub-child 2 ==> level 2
sub-Sub-child ==> level 3
What I need is to get an o/p like this. This was the database structure:
Each and every level to be view in level wise tables in laravel blade can anyone help to solve this parent
child 1 ==> level 1 child 2 ==> level 1 child 3 ==> level 1
Sub-child 1 ==> level 2 Sub-child 2 ==> level 2 Sub-child 3 ==> level 2
sub-Sub-child 3 ==> level 3 sub-Sub-child 3 ==> level 3 sub-Sub-child 3 ==> level 3
Code I was using in eloquent orm:
public function childs()
{
return $this->hasMany('App\Model \clients','under_reference','reference_id','id')
->leftjoin('clients_payment_type', function($join) {
$join->on('clients_payment_type.user_id', '=', 'clients.id');
});
}
Code I was using in view blade
@foreach($childs as $child)
@if(count($child->GrandChild) > 0 )
@include('AdminLayout.levelTwo',['childs' => $child->childs])
@endif
@endforeach
Same as continues in laravel blade for level one 2 and three can anyone help me to solve this...
来源:https://stackoverflow.com/questions/59046609/how-do-i-get-all-children-that-fall-under-a-multiple-parent-id-using-eloquent-fo