1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Application\Model; |
6
|
|
|
|
7
|
|
|
use Application\DBAL\Types\BookingTypeType; |
8
|
|
|
use Application\Traits\HasCode; |
9
|
|
|
use Application\Traits\HasDescription; |
10
|
|
|
use Application\Traits\HasName; |
11
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
12
|
|
|
use Doctrine\Common\Collections\Collection; |
13
|
|
|
use Doctrine\ORM\Mapping as ORM; |
14
|
|
|
use GraphQL\Doctrine\Annotation as API; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* An item that can be booked by a user |
18
|
|
|
* |
19
|
|
|
* @ORM\Entity(repositoryClass="Application\Repository\BookableRepository") |
20
|
|
|
*/ |
21
|
|
|
class Bookable extends AbstractModel |
22
|
|
|
{ |
23
|
|
|
use HasName; |
24
|
|
|
use HasDescription; |
25
|
|
|
use HasCode; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var string |
29
|
|
|
* |
30
|
|
|
* @ORM\Column(type="decimal", length=10, options={"default" = "0"}) |
31
|
|
|
*/ |
32
|
|
|
private $initialPrice = '0.00'; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var string |
36
|
|
|
* |
37
|
|
|
* @ORM\Column(type="decimal", length=10, options={"default" = "0"}) |
38
|
|
|
*/ |
39
|
|
|
private $periodicPrice = '0.00'; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var int |
43
|
|
|
* |
44
|
|
|
* @ORM\Column(type="smallint", options={"unsigned" = true, "default" = "1"}) |
45
|
|
|
*/ |
46
|
|
|
private $simultaneousBookingMaximum = 1; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @var string |
50
|
|
|
* |
51
|
|
|
* @ORM\Column(type="BookingType", length=10, options={"default" = BookingTypeType::SELF_APPROVED}) |
52
|
|
|
*/ |
53
|
|
|
private $bookingType = BookingTypeType::SELF_APPROVED; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var BookableType |
57
|
|
|
* @ORM\ManyToOne(targetEntity="BookableType") |
58
|
|
|
*/ |
59
|
|
|
private $type; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @var Collection |
63
|
|
|
* @ORM\ManyToMany(targetEntity="Booking", mappedBy="bookables") |
64
|
|
|
*/ |
65
|
|
|
private $bookings; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @var Collection |
69
|
|
|
* @ORM\ManyToMany(targetEntity="License", mappedBy="bookables") |
70
|
|
|
*/ |
71
|
|
|
private $tags; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Constructor |
75
|
|
|
*/ |
76
|
|
|
public function __construct() |
77
|
|
|
{ |
78
|
|
|
$this->bookings = new ArrayCollection(); |
79
|
|
|
$this->tags = new ArrayCollection(); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @return Collection |
84
|
|
|
*/ |
85
|
|
|
public function getBookings(): Collection |
86
|
|
|
{ |
87
|
|
|
return $this->bookings; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @return Collection |
92
|
|
|
*/ |
93
|
|
|
public function getTags(): Collection |
94
|
|
|
{ |
95
|
|
|
return $this->tags; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @return BookableType |
100
|
|
|
*/ |
101
|
|
|
public function getType(): BookableType |
102
|
|
|
{ |
103
|
|
|
return $this->type; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @param BookableType $type |
108
|
|
|
*/ |
109
|
|
|
public function setType(BookableType $type): void |
110
|
|
|
{ |
111
|
|
|
$this->type = $type; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @return string |
116
|
|
|
*/ |
117
|
|
|
public function getInitialPrice(): string |
118
|
|
|
{ |
119
|
|
|
return $this->initialPrice; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @param string $initialPrice |
124
|
|
|
*/ |
125
|
|
|
public function setInitialPrice(string $initialPrice): void |
126
|
|
|
{ |
127
|
|
|
$this->initialPrice = $initialPrice; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @return string |
132
|
|
|
*/ |
133
|
|
|
public function getPeriodicPrice(): string |
134
|
|
|
{ |
135
|
|
|
return $this->periodicPrice; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* @param string $periodicPrice |
140
|
|
|
*/ |
141
|
|
|
public function setPeriodicPrice(string $periodicPrice): void |
142
|
|
|
{ |
143
|
|
|
$this->periodicPrice = $periodicPrice; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* @return int |
148
|
|
|
*/ |
149
|
|
|
public function getSimultaneousBookingMaximum(): int |
150
|
|
|
{ |
151
|
|
|
return $this->simultaneousBookingMaximum; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* @param int $simultaneousBookingMaximum |
156
|
|
|
*/ |
157
|
|
|
public function setSimultaneousBookingMaximum(int $simultaneousBookingMaximum): void |
158
|
|
|
{ |
159
|
|
|
$this->simultaneousBookingMaximum = $simultaneousBookingMaximum; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* @API\Field(type="BookingType") |
164
|
|
|
* |
165
|
|
|
* @return string |
166
|
|
|
*/ |
167
|
|
|
public function getBookingType(): string |
168
|
|
|
{ |
169
|
|
|
return $this->bookingType; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* @API\Input(type="BookingType") |
174
|
|
|
* |
175
|
|
|
* @param string $bookingType |
176
|
|
|
*/ |
177
|
|
|
public function setBookingType(string $bookingType): void |
178
|
|
|
{ |
179
|
|
|
$this->bookingType = $bookingType; |
180
|
|
|
} |
181
|
|
|
} |
182
|
|
|
|