1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Models\Concerns\Item; |
4
|
|
|
|
5
|
|
|
use App\Models\Denomination; |
6
|
|
|
use App\Models\Order; |
7
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @property int $order_id Foreign key of \App\Models\Order. |
11
|
|
|
* @property-read \App\Models\Order $order |
12
|
|
|
* @property int $denomination_id Foreign key of \App\Models\Denomination. |
13
|
|
|
* @property-read \App\Models\Denomination $denomination |
14
|
|
|
* |
15
|
|
|
* @see \App\Models\Item |
16
|
|
|
*/ |
17
|
|
|
trait Relation |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* Define an inverse one-to-one or many relationship with \App\Models\Order. |
21
|
|
|
* |
22
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
23
|
|
|
*/ |
24
|
|
|
public function order(): BelongsTo |
25
|
|
|
{ |
26
|
|
|
return $this->belongsTo(Order::class); |
|
|
|
|
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Return \App\Models\Order model relation value. |
31
|
|
|
* |
32
|
|
|
* @return \App\Models\Order |
33
|
|
|
*/ |
34
|
|
|
public function getOrderRelationValue(): Order |
35
|
|
|
{ |
36
|
|
|
return $this->getRelationValue('order'); |
|
|
|
|
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Set \App\Models\Order model relation value. |
41
|
|
|
* |
42
|
|
|
* @param \App\Models\Order $order |
43
|
|
|
* @return $this |
44
|
|
|
*/ |
45
|
|
|
public function setOrderRelationValue(Order $order) |
46
|
|
|
{ |
47
|
|
|
$this->order()->associate($order); |
48
|
|
|
|
49
|
|
|
return $this; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Define an inverse one-to-one or many relationship with \App\Models\Denomination. |
54
|
|
|
* |
55
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
56
|
|
|
*/ |
57
|
2 |
|
public function denomination(): BelongsTo |
58
|
|
|
{ |
59
|
2 |
|
return $this->belongsTo(Denomination::class); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Return \App\Models\Denomination model relation value. |
64
|
|
|
* |
65
|
|
|
* @return \App\Models\Denomination |
66
|
|
|
*/ |
67
|
2 |
|
public function getDenominationRelationValue(): Denomination |
68
|
|
|
{ |
69
|
2 |
|
return $this->getRelationValue('denomination'); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Set \App\Models\Denomination model relation value. |
74
|
|
|
* |
75
|
|
|
* @param \App\Models\Denomination $denomination |
76
|
|
|
* @return $this |
77
|
|
|
*/ |
78
|
|
|
public function setDenominationRelationValue(Denomination $denomination) |
79
|
|
|
{ |
80
|
|
|
$this->denomination()->associate($denomination); |
81
|
|
|
|
82
|
|
|
return $this; |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|