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 ?: ''; } public function matchableFilters() { $name_parts = collect(explode(' ', $this->name)); $out = $name_parts->map( function ($value) { return ['string', $value]; } ); return $out; } }