heihachi88
6/7/2014 - 7:01 PM

Eloquent - one to many relationship

Eloquent - one to many relationship

You have to create "user_id" column in a table "comments"
class User extends Eloquent {
  public function comments() {
    return $this->hasMany('Comment');
  }
}
class Comment extends Eloquent {
  public function user() {
    return $this->belongsTo('User');
  }
}