summaryrefslogtreecommitdiff
path: root/app/Rugby/Model/Match.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Rugby/Model/Match.php')
-rw-r--r--app/Rugby/Model/Match.php25
1 files changed, 18 insertions, 7 deletions
diff --git a/app/Rugby/Model/Match.php b/app/Rugby/Model/Match.php
index 5447ef5..58a3dd9 100644
--- a/app/Rugby/Model/Match.php
+++ b/app/Rugby/Model/Match.php
@@ -2,19 +2,13 @@
namespace App\Rugby\Model;
-use App\Rugby\Model\Team;
-use App\Rugby\Model\Tournament;
-use App\Rugby\Model\Venue;
-
use Illuminate\Database\Eloquent\Model;
class Match extends Model
{
protected $table = 'matches';
-
protected $casts = ['date' => 'datetime:Y-m-d'];
-
- protected $fillable = ['score', 'half_score', 'referee', 'date'];
+ protected $fillable = ['score', 'half_score', 'referee', 'date'];
public function teams()
{
@@ -42,6 +36,17 @@ class Match extends Model
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 homeTeam()
{
return $this->teams()->wherePivot('is_home', '=', true);
@@ -56,4 +61,10 @@ class Match extends Model
{
return $this->belongsToMany(Tournament::class, 'match_tournament');
}
+
+ public function videos()
+ {
+ return $this->hasMany(Video::class, 'match_id');
+ }
+
}