Passed
Pull Request — master (#53)
by
unknown
05:24
created

Match   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 34
ccs 0
cts 20
cp 0
rs 10
wmc 5
1
<?php
2
3
namespace App;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class Match extends Model
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_MATCH, expecting T_STRING on line 7 at column 6
Loading history...
8
{
9
    const WAITING = 0;
10
    const RUNNING = 1;
11
    const PAUSED = 2;
12
    const FINISHED = 3;
13
    const NEED_DECISION = 4;
14
    const INVALID = 5;
15
    const EMPTY_PLACE = -1;
16
17
    public function fight()
18
    {
19
        return $this->belongsTo(Fight::class);
20
    }
21
22
    public function winner()
23
    {
24
        return $this->belongsTo(Competitor::class, 'winner_id');
25
    }
26
27
    public function assignReferees($referees)
28
    {
29
        $this->referees()->detach();
30
        foreach ($referees as $position => $referee) {
31
            $this->referees()->attach($referee, [
32
                'position' => $position
33
            ]);
34
35
        }
36
    }
37
38
    public function referees()
39
    {
40
        return $this->hasMany(Referee::class);
41
    }
42
}
43