foreach loop is iterating same values in join statment

  laravel, loops

I m new to laravel and making a search app for homeo remedies i am facing following problem
$remAilProps = DB::table(‘remedies’)

    ->join('ailment_modules', 'remedies.id', '=', 'ailment_modules.rem_id')
    ->join('ailments', 'ailment_modules.ail_id','=','ailments.id')
    
    ->join('ailment_modules as ail','ailments.id','=','ail.ail_id')
    ->join('ailment_props','ail.ail_id','=','ailment_props.ail_id')
    ->join('props','ailment_props.props_id','=','props.id')
    ->join('props_values','props.id','=','props_values.props_id')
    ->select('ailment','props','propsValue')
    ->distinct()
    ->groupBy('propsValue')
    ->keyBy('ailment')
    ->where('remedies.id','=',$id)
    
    
    ->get();
    
    return view('layout.navitems.users')
                ->with('ailment',Ailments::all())
                ->with('rem',Remedy::where('id','=',$id)->firstOrFail())
                ->with('org',Organs::all())
                ->with('remedy',Remedy::all())
                ->with('remAilProps', $remAilProps);
                
            }

when i loop it blade view the result is like
Diarhoea color,
green Diarhoea discharge,
profuse Diarhoea discharge,
scanty Diarhoea color,
yellow

i want to not iterate Diarhoea every time and also color and discharge
I have search lot but nothing solve my problems

Source: Laravel

Leave a Reply