Passed
Push — develop ( 7c7ccb...ccfa35 )
by Francisco
02:39
created

ExchangeRegistryEntry::toStudent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Judite\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use App\Judite\Contracts\Registry\ExchangeRegistryEntry as ExchangeRegistryEntryContract;
7
8
class ExchangeRegistryEntry extends Model implements ExchangeRegistryEntryContract
9
{
10
    /**
11
     * The table associated with the model.
12
     *
13
     * @var string
14
     */
15
    protected $table = 'log_exchanges';
16
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function fromShift()
21
    {
22
        return $this->fromShiftRelation()->first();
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function toShift()
29
    {
30
        return $this->toShiftRelation()->first();
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function fromStudent()
37
    {
38
        return $this->fromStudentRelation()->first();
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function toStudent()
45
    {
46
        return $this->toStudentRelation()->first();
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function course()
53
    {
54
        return $this->toShift->course;
0 ignored issues
show
Bug introduced by
The property toShift does not exist on App\Judite\Models\ExchangeRegistryEntry. Did you mean toShiftRelation?
Loading history...
55
    }
56
57
    /**
58
     * Get source shift of this recorded exchange.
59
     *
60
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
61
     */
62
    public function fromShiftRelation()
63
    {
64
        return $this->belongsTo(Shift::class, 'from_shift_id');
65
    }
66
67
    /**
68
     * Get target shift of this recorded exchange.
69
     *
70
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
71
     */
72
    public function toShiftRelation()
73
    {
74
        return $this->belongsTo(Shift::class, 'to_shift_id');
75
    }
76
77
    /**
78
     * Get source student of this recorded exchange.
79
     *
80
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
81
     */
82
    public function fromStudentRelation()
83
    {
84
        return $this->belongsTo(Student::class, 'from_student_id');
85
    }
86
87
    /**
88
     * Get target student of this recorded exchange.
89
     *
90
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
91
     */
92
    public function toStudentRelation()
93
    {
94
        return $this->belongsTo(Student::class, 'to_student_id');
95
    }
96
}
97