hasMany does not work properly

Asked

Viewed 36 times

0

good night!! I’m trying to launch data report(groups and networks) but it doesn’t work...the group model is like this:

function Redes(){
     return $this->hasMany('App\rede','grupo_id','id');
}

in the network model is like this:

class rede extends Model
{
  protected $table = "redes";
}

I’m trying to display the data like this:

Function Index(groups $groups, network $network){

    $lista = $grupos->all();
    foreach($lista as $li):

        foreach($li->Redes() as $d):
            print_r($d->id);
       endforeach;

    endforeach;
}

And nothing, what’s wrong? Thank you for your constant attention!!!

  • 1

    It wouldn’t just be $li->Redes?

  • Anderson...truth!! I always forget...man, thank you very much!!! thanks even!!!!!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.