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