Hi @mvnobrega your model Grupo hasMany Relato, so,
$grupo->relatos
is collection. you can't access comments on it. Try to do something like:
public function grupoPerfil($slug)
{
$grupo = Grupo::where('slug', $slug)->first();
$comments = Comment::whereHas('relato', function ($query) use ($grupo) {
return $query->where('grupo_id', $grupo->id);
})->paginate(10);
return view('grupo', compact(['grupo', 'comments']));
}
this approach assumes that you have relation in your Comment Model
class Comment extends Model
{
public function relato()
{
return $this->belongsTo('App\Relato');
}
}