1 year ago

One to many Definition and Foreign Key

Posted 1 year ago by Opulido

I have seen on tutorials people declaring the foreign key on one to many scenarios and others do not use it. Which is the way to go? Should we always use the foreing key definition, for example:


and second question, how to reference the model class in the relationship:

    return $this->hasMany('App\Comment');      This one
    return $this->hasMany(Comment::class);     Or this one

Regards, Omar

Please sign in or create an account to participate in this conversation.