belongsToMany(Match::class)->withPivot('is_home'); } public function homeMatches() { return $this->matches()->wherePivot('is_home', '=', true); } public function awayMatches() { return $this->matches()->wherePivot('is_home', '=', false); } public function getName() { return $this->name ?: ''; } }