summaryrefslogtreecommitdiff
path: root/app/Rugby/Model
diff options
context:
space:
mode:
Diffstat (limited to 'app/Rugby/Model')
-rw-r--r--app/Rugby/Model/Match.php9
-rw-r--r--app/Rugby/Model/Tournament.php5
-rw-r--r--app/Rugby/Model/Video.php5
3 files changed, 9 insertions, 10 deletions
diff --git a/app/Rugby/Model/Match.php b/app/Rugby/Model/Match.php
index 58a3dd9..38d58d8 100644
--- a/app/Rugby/Model/Match.php
+++ b/app/Rugby/Model/Match.php
@@ -47,14 +47,14 @@ class Match extends Model
return $video->getUrl();
}
- public function homeTeam()
+ public function getHomeTeam()
{
- return $this->teams()->wherePivot('is_home', '=', true);
+ return $this->teams()->wherePivot('is_home', '=', true)->first();
}
- public function awayTeam()
+ public function getAwayTeam()
{
- return $this->teams()->wherePivot('is_home', '=', false);
+ return $this->teams()->wherePivot('is_home', '=', false)->first();
}
public function tournaments()
@@ -66,5 +66,4 @@ class Match extends Model
{
return $this->hasMany(Video::class, 'match_id');
}
-
}
diff --git a/app/Rugby/Model/Tournament.php b/app/Rugby/Model/Tournament.php
index 3ab6352..5c81278 100644
--- a/app/Rugby/Model/Tournament.php
+++ b/app/Rugby/Model/Tournament.php
@@ -12,7 +12,6 @@ class Tournament extends Model
use Matchable;
protected $table = 'tournaments';
-
protected $fillable = ['name'];
public function matchableFilters()
@@ -25,6 +24,10 @@ class Tournament extends Model
return ['date', $value];
}
+ if ($this->isNumeric($value)) {
+ return ['number', $value];
+ }
+
return ['string', $value];
}
);
diff --git a/app/Rugby/Model/Video.php b/app/Rugby/Model/Video.php
index 2182b65..48da15e 100644
--- a/app/Rugby/Model/Video.php
+++ b/app/Rugby/Model/Video.php
@@ -10,7 +10,7 @@ class Video extends Model
{
protected $table = 'videos';
protected $casts = ['date' => 'datetime:Y-m-d'];
- protected $fillable = ['path'];
+ protected $fillable = ['path', 'url'];
public function match()
{
@@ -27,8 +27,5 @@ class Video extends Model
public function getUrl(): string
{
return asset('storage/matches/' . $this->getFilename());
- // return Storage::disk('local')->url(
- // 'matches/' . $this->getFilename()
- // );
}
}