diff options
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); |