diff options
author | Fbenas <philbeansburton@gmail.com> | 2020-06-20 21:07:45 +0100 |
---|---|---|
committer | Fbenas <philbeansburton@gmail.com> | 2020-06-20 21:07:45 +0100 |
commit | 8d6e8b306d7836e4075a13ad98617bfe5afaa1a0 (patch) | |
tree | 99c44e28da231cac0d9e513aabc1ee0768972426 /app/Rugby/Model/Tournament.php | |
parent | 897b68ac107f2fb0d4dc1d31ce96ce24c862eb27 (diff) |
Add new scripts for youtube downloading and syncing with existing matches
Diffstat (limited to 'app/Rugby/Model/Tournament.php')
-rw-r--r-- | app/Rugby/Model/Tournament.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/app/Rugby/Model/Tournament.php b/app/Rugby/Model/Tournament.php index 64d9a45..3ab6352 100644 --- a/app/Rugby/Model/Tournament.php +++ b/app/Rugby/Model/Tournament.php @@ -2,16 +2,36 @@ namespace App\Rugby\Model; +use App\Rugby\Concerns\Matchable; use App\Rugby\Model\Match; use Illuminate\Database\Eloquent\Model; class Tournament extends Model { + use Matchable; + protected $table = 'tournaments'; protected $fillable = ['name']; + public function matchableFilters() + { + $name_parts = collect(explode(' ', $this->name)); + + $out = $name_parts->map( + function ($value) { + if ($this->isDate($value)) { + return ['date', $value]; + } + + return ['string', $value]; + } + ); + + return $out; + } + public function matches() { return $this->belongsToMany(Match::class); |