blob: 3ab6352f85edc82bd437061e80224d82c123eef0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
<?php
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);
}
}
|