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; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* {@inheritdoc} |
27
|
|
|
*/ |
28
|
|
|
public function toShift() |
29
|
|
|
{ |
30
|
|
|
return $this->toShiftRelation; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* {@inheritdoc} |
35
|
|
|
*/ |
36
|
|
|
public function fromStudent() |
37
|
|
|
{ |
38
|
|
|
return $this->fromStudentRelation; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* {@inheritdoc} |
43
|
|
|
*/ |
44
|
|
|
public function toStudent() |
45
|
|
|
{ |
46
|
|
|
return $this->toStudentRelation; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* {@inheritdoc} |
51
|
|
|
*/ |
52
|
|
|
public function course() |
53
|
|
|
{ |
54
|
|
|
return $this->fromShiftRelation->course; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* {@inheritdoc} |
59
|
|
|
*/ |
60
|
|
|
public function getDate() |
61
|
|
|
{ |
62
|
|
|
return $this->created_at; |
|
|
|
|
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Get source shift of this recorded exchange. |
67
|
|
|
* |
68
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
69
|
|
|
*/ |
70
|
|
|
public function fromShiftRelation() |
71
|
|
|
{ |
72
|
|
|
return $this->belongsTo(Shift::class, 'from_shift_id'); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Get target shift of this recorded exchange. |
77
|
|
|
* |
78
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
79
|
|
|
*/ |
80
|
|
|
public function toShiftRelation() |
81
|
|
|
{ |
82
|
|
|
return $this->belongsTo(Shift::class, 'to_shift_id'); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Get source student of this recorded exchange. |
87
|
|
|
* |
88
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
89
|
|
|
*/ |
90
|
|
|
public function fromStudentRelation() |
91
|
|
|
{ |
92
|
|
|
return $this->belongsTo(Student::class, 'from_student_id'); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Get target student of this recorded exchange. |
97
|
|
|
* |
98
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
99
|
|
|
*/ |
100
|
|
|
public function toStudentRelation() |
101
|
|
|
{ |
102
|
|
|
return $this->belongsTo(Student::class, 'to_student_id'); |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: