'datetime:Y-m-d']; protected $fillable = ['score', 'half_score', 'referee', 'date']; public function teams() { return $this->belongsToMany(Team::class, 'match_team'); } public function venue() { return $this->hasOne(Venue::class, 'id'); } public function getDisplayName() { $venue = Venue::find($this->venue_id); if (!$venue) { return 'Unknown'; } return $venue->name; } public function getDisplayDate() { return (new \Carbon\Carbon($this->date))->format('M d Y'); } public function getVideoUrl() { $video = $this->videos()->first(); if (! $video) { return ''; } return $video->getUrl(); } public function getHomeTeam() { return $this->teams()->wherePivot('is_home', '=', true)->first(); } public function getAwayTeam() { return $this->teams()->wherePivot('is_home', '=', false)->first(); } public function tournaments() { return $this->belongsToMany(Tournament::class, 'match_tournament'); } public function videos() { return $this->hasMany(Video::class, 'match_id'); } }