Relationships

Relationships are generated based on your YAML definition:

// belongsTo relationship
public function user()
{
    return $this->belongsTo(User::class, 'user_id', 'id');
}

// hasOne relationship
public function profile()
{
    return $this->hasOne(Profile::class, 'user_id', 'id');
}

// hasMany relationship
public function comments()
{
    return $this->hasMany(Comment::class, 'post_id', 'id');
}

Last updated