From d1fe4536cc039450b540104e382db0d01d5cf886 Mon Sep 17 00:00:00 2001 From: Fbenas Date: Fri, 19 Jun 2020 02:16:51 +0100 Subject: Initial commit --- app/Rugby/Model/Team.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 app/Rugby/Model/Team.php (limited to 'app/Rugby/Model/Team.php') diff --git a/app/Rugby/Model/Team.php b/app/Rugby/Model/Team.php new file mode 100644 index 0000000..2582f33 --- /dev/null +++ b/app/Rugby/Model/Team.php @@ -0,0 +1,34 @@ +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 ?: ''; + } +} -- cgit v1.2.3