Releases: staudenmeir/belongs-to-through
Releases · staudenmeir/belongs-to-through
Version 2.2.2
See CHANGELOG.
Version 2.2.1
Version 2.2
Changes in this version:
- Included support for non-conventional foreign key column names.
Version 2.1
Changes:
- Prefixed keys allowed in lowest level of deep BelongsToThrough relation.
Version 2.0
- BelongsToThrough relation with more than one through models.
Version 2.0
- Deeper relations.
Version 1.0.1
Bug fixes:
- Fixed issue with eager loading.
Version 1.0
Consider a blog application. In this app, a country can have many users and a user can have many articles. So, hasManyThrough
provides easy way to access articles from a country.
class Country extends Model {
public function articles () {
return $this->hasManyThrough(Article::class, User::class);
}
}
If we are accessing the country of the article, then we have to use $article->user->country
.
Class Article extends Model {
public function country() {
return $this->belongsToThrough(Country::class, User::class);
}
}
Now, the magic: $article->country