| @@ 57-182 (lines=126) @@ | ||
| 54 | * toDateMethod="getToDate", |
|
| 55 | * ) |
|
| 56 | */ |
|
| 57 | class Availability implements EntityInterface |
|
| 58 | { |
|
| 59 | use Traits\PropertyIdGeneratedTrait; |
|
| 60 | ||
| 61 | /** |
|
| 62 | * @var int |
|
| 63 | * @ORM\Column(name="places", type="integer", nullable=false) |
|
| 64 | * |
|
| 65 | * @Assert\PositiveOrZero() |
|
| 66 | * |
|
| 67 | * @Serializer\Groups({"get", "put", "post"}) |
|
| 68 | * @OA\ApiProperty( |
|
| 69 | * attributes={ |
|
| 70 | * "swagger_context"={"type"="integer", "example"=100}, |
|
| 71 | * } |
|
| 72 | * ) |
|
| 73 | * @OA\ApiFilter( |
|
| 74 | * ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\RangeFilter::class |
|
| 75 | * ) |
|
| 76 | * @OA\ApiFilter( |
|
| 77 | * ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter::class, |
|
| 78 | * strategy="exact" |
|
| 79 | * ) |
|
| 80 | */ |
|
| 81 | private $places; |
|
| 82 | ||
| 83 | /** |
|
| 84 | * @var \DateTimeImmutable |
|
| 85 | * @ORM\Column(name="from_date", type="date_immutable", nullable=false) |
|
| 86 | * |
|
| 87 | * @Assert\Date() |
|
| 88 | * |
|
| 89 | * @Serializer\Groups({"get", "put", "post"}) |
|
| 90 | * @OA\ApiProperty( |
|
| 91 | * attributes={ |
|
| 92 | * "swagger_context"={"type"="string", "format"="date_immutable", "example"="2000-01-01"}, |
|
| 93 | * "normalization_context"={"date_format"="Y-m-d", "datetime_format"="Y-m-d"}, |
|
| 94 | * } |
|
| 95 | * ) |
|
| 96 | * @OA\ApiFilter( |
|
| 97 | * ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter::class, |
|
| 98 | * strategy="ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter::INCLUDE_NULL_BEFORE" |
|
| 99 | * ) |
|
| 100 | * @OA\ApiFilter( |
|
| 101 | * ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter::class, |
|
| 102 | * strategy="exact" |
|
| 103 | * ) |
|
| 104 | */ |
|
| 105 | private $fromDate; |
|
| 106 | ||
| 107 | /** |
|
| 108 | * @var \DateTimeImmutable |
|
| 109 | * @ORM\Column(name="to_date", type="date_immutable", nullable=false) |
|
| 110 | * |
|
| 111 | * @Assert\Date() |
|
| 112 | * @Assert\GreaterThan(propertyPath="fromDate") |
|
| 113 | * |
|
| 114 | * @Serializer\Groups({"get", "put", "post"}) |
|
| 115 | * @OA\ApiProperty( |
|
| 116 | * attributes={ |
|
| 117 | * "swagger_context"={"type"="string", "format"="date_immutable", "example"="2000-01-01"}, |
|
| 118 | * "normalization_context"={"date_format"="Y-m-d", "datetime_format"="Y-m-d"}, |
|
| 119 | * } |
|
| 120 | * ) |
|
| 121 | * @OA\ApiFilter( |
|
| 122 | * ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter::class, |
|
| 123 | * strategy="ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter::INCLUDE_NULL_BEFORE" |
|
| 124 | * ) |
|
| 125 | * @OA\ApiFilter( |
|
| 126 | * ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter::class, |
|
| 127 | * strategy="exact" |
|
| 128 | * ) |
|
| 129 | */ |
|
| 130 | private $toDate; |
|
| 131 | ||
| 132 | //------------------------------------------------------------------------------------------- |
|
| 133 | ||
| 134 | public function __construct( |
|
| 135 | int $places, |
|
| 136 | \DateTimeImmutable $fromDate, |
|
| 137 | \DateTimeImmutable $toDate |
|
| 138 | ) { |
|
| 139 | $this->id = ShortUuid::uuid4(); |
|
| 140 | $this->places = $places; |
|
| 141 | $this->setFromDate($fromDate); |
|
| 142 | $this->setToDate($toDate); |
|
| 143 | } |
|
| 144 | ||
| 145 | //------------------------------------------------------------------------------------------- |
|
| 146 | ||
| 147 | public function getPlaces(): int |
|
| 148 | { |
|
| 149 | return $this->places; |
|
| 150 | } |
|
| 151 | ||
| 152 | public function setPlaces(int $places): self |
|
| 153 | { |
|
| 154 | $this->places = $places; |
|
| 155 | ||
| 156 | return $this; |
|
| 157 | } |
|
| 158 | ||
| 159 | public function getFromDate(): \DateTimeImmutable |
|
| 160 | { |
|
| 161 | return $this->fromDate; |
|
| 162 | } |
|
| 163 | ||
| 164 | public function setFromDate(\DateTimeImmutable $fromDate): self |
|
| 165 | { |
|
| 166 | $this->fromDate = $fromDate; |
|
| 167 | ||
| 168 | return $this; |
|
| 169 | } |
|
| 170 | ||
| 171 | public function getToDate(): \DateTimeImmutable |
|
| 172 | { |
|
| 173 | return $this->toDate; |
|
| 174 | } |
|
| 175 | ||
| 176 | public function setToDate(\DateTimeImmutable $toDate): self |
|
| 177 | { |
|
| 178 | $this->toDate = $toDate; |
|
| 179 | ||
| 180 | return $this; |
|
| 181 | } |
|
| 182 | } |
|
| 183 | ||
| @@ 55-194 (lines=140) @@ | ||
| 52 | * } |
|
| 53 | * ) |
|
| 54 | */ |
|
| 55 | class MemberNeed implements EntityInterface, GetMemberInterface |
|
| 56 | { |
|
| 57 | use Traits\PropertyIdGeneratedTrait; |
|
| 58 | ||
| 59 | /** |
|
| 60 | * @var \DateTimeImmutable |
|
| 61 | * @ORM\Column(name="date", type="date_immutable", nullable=false) |
|
| 62 | * |
|
| 63 | * @Assert\Date() |
|
| 64 | * |
|
| 65 | * @Serializer\Groups({"get", "put", "post"}) |
|
| 66 | * @@OA\ApiProperty( |
|
| 67 | * attributes={ |
|
| 68 | * "swagger_context"={"type"="string", "format"="date_immutable", "example"="2000-01-01"}, |
|
| 69 | * "normalization_context"={"date_format"="Y-m-d", "datetime_format"="Y-m-d"}, |
|
| 70 | * } |
|
| 71 | * ) |
|
| 72 | * @OA\ApiFilter( |
|
| 73 | * ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter::class, |
|
| 74 | * strategy="ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter::INCLUDE_NULL_BEFORE" |
|
| 75 | * ) |
|
| 76 | * @OA\ApiFilter( |
|
| 77 | * ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter::class, |
|
| 78 | * strategy="exact" |
|
| 79 | * ) |
|
| 80 | */ |
|
| 81 | private $date; |
|
| 82 | ||
| 83 | /** |
|
| 84 | * @var int |
|
| 85 | * @ORM\Column(name="places", type="integer", nullable=false) |
|
| 86 | * |
|
| 87 | * @Assert\PositiveOrZero() |
|
| 88 | * |
|
| 89 | * @Serializer\Groups({"get"}) |
|
| 90 | * @@OA\ApiProperty( |
|
| 91 | * attributes={ |
|
| 92 | * "swagger_context"={"type"="integer", "example"=0}, |
|
| 93 | * } |
|
| 94 | * ) |
|
| 95 | * @OA\ApiFilter( |
|
| 96 | * ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\RangeFilter::class |
|
| 97 | * ) |
|
| 98 | * @OA\ApiFilter( |
|
| 99 | * ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter::class, |
|
| 100 | * strategy="exact" |
|
| 101 | * ) |
|
| 102 | */ |
|
| 103 | private $places; |
|
| 104 | ||
| 105 | /** |
|
| 106 | * @var string |
|
| 107 | * @ORM\Column(name="reason", type="string", length=255, nullable=false) |
|
| 108 | * |
|
| 109 | * @Assert\NotBlank() |
|
| 110 | * @Assert\Length(min="1", max="255") |
|
| 111 | * |
|
| 112 | * @Serializer\Groups({"get", "put", "post"}) |
|
| 113 | * @OA\ApiFilter( |
|
| 114 | * ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter::class, |
|
| 115 | * strategy="partial" |
|
| 116 | * ) |
|
| 117 | */ |
|
| 118 | private $reason; |
|
| 119 | ||
| 120 | //------------------------------------------------------------------------------------------- |
|
| 121 | ||
| 122 | /** |
|
| 123 | * @var Member |
|
| 124 | * @ORM\ManyToOne(targetEntity="App\Entity\Parking\Member", inversedBy="memberNeeds") |
|
| 125 | * @ORM\JoinColumn(name="member_id", referencedColumnName="id") |
|
| 126 | * |
|
| 127 | * @Assert\NotNull() |
|
| 128 | * |
|
| 129 | * @Serializer\Groups({"get", "post"}) |
|
| 130 | * @OA\ApiProperty() |
|
| 131 | * @OA\ApiSubresource(maxDepth=1) |
|
| 132 | * @OA\ApiFilter( |
|
| 133 | * ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter::class, |
|
| 134 | * strategy="exact" |
|
| 135 | * ) |
|
| 136 | * @OA\ApiFilter( |
|
| 137 | * ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter::class, |
|
| 138 | * strategy="exact", |
|
| 139 | * properties={"member.id"} |
|
| 140 | * ) |
|
| 141 | */ |
|
| 142 | protected $member; |
|
| 143 | ||
| 144 | //------------------------------------------------------------------------------------------- |
|
| 145 | ||
| 146 | public function __construct( |
|
| 147 | Member $member, |
|
| 148 | int $places, |
|
| 149 | string $reason, |
|
| 150 | \DateTimeImmutable $date |
|
| 151 | ) { |
|
| 152 | $this->id = ShortUuid::uuid4(); |
|
| 153 | $this->member = $member; |
|
| 154 | $this->places = $places; |
|
| 155 | $this->setReason($reason); |
|
| 156 | $this->setDate($date); |
|
| 157 | } |
|
| 158 | ||
| 159 | //------------------------------------------------------------------------------------------- |
|
| 160 | ||
| 161 | public function getMember(): Member |
|
| 162 | { |
|
| 163 | return $this->member; |
|
| 164 | } |
|
| 165 | ||
| 166 | public function getPlaces(): int |
|
| 167 | { |
|
| 168 | return $this->places; |
|
| 169 | } |
|
| 170 | ||
| 171 | public function getReason(): string |
|
| 172 | { |
|
| 173 | return $this->reason; |
|
| 174 | } |
|
| 175 | ||
| 176 | public function setReason(string $reason): self |
|
| 177 | { |
|
| 178 | $this->reason = $reason; |
|
| 179 | ||
| 180 | return $this; |
|
| 181 | } |
|
| 182 | ||
| 183 | public function getDate(): \DateTimeImmutable |
|
| 184 | { |
|
| 185 | return $this->date; |
|
| 186 | } |
|
| 187 | ||
| 188 | public function setDate(\DateTimeImmutable $date): self |
|
| 189 | { |
|
| 190 | $this->date = $date; |
|
| 191 | ||
| 192 | return $this; |
|
| 193 | } |
|
| 194 | } |
|
| 195 | ||
| @@ 58-203 (lines=146) @@ | ||
| 55 | * } |
|
| 56 | * ) |
|
| 57 | */ |
|
| 58 | class Reservation implements EntityInterface, GetMemberInterface |
|
| 59 | { |
|
| 60 | use Traits\PropertyIdGeneratedTrait; |
|
| 61 | ||
| 62 | /** |
|
| 63 | * @var \DateTimeImmutable |
|
| 64 | * @ORM\Column(name="date", type="date_immutable", nullable=false) |
|
| 65 | * |
|
| 66 | * @Assert\Date() |
|
| 67 | * |
|
| 68 | * @Serializer\Groups({"get"}) |
|
| 69 | * @OA\ApiProperty( |
|
| 70 | * attributes={ |
|
| 71 | * "swagger_context"={"type"="string", "format"="date", "example"="2000-01-01"}, |
|
| 72 | * "normalization_context"={"date_format"="Y-m-d", "datetime_format"="Y-m-d"}, |
|
| 73 | * } |
|
| 74 | * ) |
|
| 75 | * @OA\ApiFilter( |
|
| 76 | * ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter::class, |
|
| 77 | * strategy="ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter::INCLUDE_NULL_BEFORE" |
|
| 78 | * ) |
|
| 79 | * @OA\ApiFilter( |
|
| 80 | * ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter::class, |
|
| 81 | * strategy="exact" |
|
| 82 | * ) |
|
| 83 | */ |
|
| 84 | private $date; |
|
| 85 | ||
| 86 | /** |
|
| 87 | * @var string |
|
| 88 | * @ORM\Column(name="type", type="string", length=50, nullable=false) |
|
| 89 | * |
|
| 90 | * @Assert\NotBlank() |
|
| 91 | * @Assert\Type("string") |
|
| 92 | * @Assert\Length(min="1", max="50") |
|
| 93 | * |
|
| 94 | * @Serializer\Groups({"get"}) |
|
| 95 | * @OA\ApiProperty( |
|
| 96 | * attributes={ |
|
| 97 | * "swagger_context"={"type"="string", "enum"={"REVOKED","ASSIGNED"}, "example"="REVOKED"}, |
|
| 98 | * } |
|
| 99 | * ) |
|
| 100 | * @OA\ApiFilter( |
|
| 101 | * ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter::class, |
|
| 102 | * strategy="exact" |
|
| 103 | * ) |
|
| 104 | */ |
|
| 105 | private $type; |
|
| 106 | ||
| 107 | /** |
|
| 108 | * @var int |
|
| 109 | * @ORM\Column(name="places", type="integer", nullable=false) |
|
| 110 | * |
|
| 111 | * @Assert\PositiveOrZero() |
|
| 112 | * |
|
| 113 | * @Serializer\Groups({"get"}) |
|
| 114 | * @OA\ApiProperty( |
|
| 115 | * attributes={ |
|
| 116 | * "swagger_context"={"type"="integer", "example"=1}, |
|
| 117 | * } |
|
| 118 | * ) |
|
| 119 | * @OA\ApiFilter( |
|
| 120 | * ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\RangeFilter::class |
|
| 121 | * ) |
|
| 122 | * @OA\ApiFilter( |
|
| 123 | * ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter::class, |
|
| 124 | * strategy="exact" |
|
| 125 | * ) |
|
| 126 | */ |
|
| 127 | private $places; |
|
| 128 | ||
| 129 | //------------------------------------------------------------------------------------------- |
|
| 130 | ||
| 131 | /** |
|
| 132 | * @var Member |
|
| 133 | * @ORM\ManyToOne(targetEntity="App\Entity\Parking\Member") |
|
| 134 | * @ORM\JoinColumn(name="member_id", referencedColumnName="id") |
|
| 135 | * |
|
| 136 | * @Assert\NotNull() |
|
| 137 | * |
|
| 138 | * @Serializer\Groups({"get"}) |
|
| 139 | * @OA\ApiSubresource() |
|
| 140 | * @OA\ApiProperty( |
|
| 141 | * attributes={ |
|
| 142 | * "swagger_context"={"type"="string", "example"="id"}, |
|
| 143 | * } |
|
| 144 | * ) |
|
| 145 | * @OA\ApiFilter( |
|
| 146 | * ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter::class, |
|
| 147 | * strategy="exact" |
|
| 148 | * ) |
|
| 149 | * @OA\ApiFilter( |
|
| 150 | * ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter::class, |
|
| 151 | * strategy="exact", |
|
| 152 | * properties={"member.id"} |
|
| 153 | * ) |
|
| 154 | */ |
|
| 155 | protected $member; |
|
| 156 | ||
| 157 | //------------------------------------------------------------------------------------------- |
|
| 158 | ||
| 159 | public function __construct(Member $member, \DateTimeImmutable $date, int $places, ReservationTypeEnum $type) |
|
| 160 | { |
|
| 161 | $this->id = ShortUuid::uuid4(); |
|
| 162 | $this->member = $member; |
|
| 163 | $this->date = $date; |
|
| 164 | $this->setPlaces($places); |
|
| 165 | $this->setType($type); |
|
| 166 | } |
|
| 167 | ||
| 168 | //------------------------------------------------------------------------------------------- |
|
| 169 | ||
| 170 | public function getDate(): \DateTimeImmutable |
|
| 171 | { |
|
| 172 | return $this->date; |
|
| 173 | } |
|
| 174 | ||
| 175 | public function getMember(): Member |
|
| 176 | { |
|
| 177 | return $this->member; |
|
| 178 | } |
|
| 179 | ||
| 180 | public function getPlaces(): int |
|
| 181 | { |
|
| 182 | return $this->places; |
|
| 183 | } |
|
| 184 | ||
| 185 | public function setPlaces(int $places): self |
|
| 186 | { |
|
| 187 | $this->places = $places; |
|
| 188 | ||
| 189 | return $this; |
|
| 190 | } |
|
| 191 | ||
| 192 | public function getType(): ReservationTypeEnum |
|
| 193 | { |
|
| 194 | return new ReservationTypeEnum($this->type); |
|
| 195 | } |
|
| 196 | ||
| 197 | public function setType(ReservationTypeEnum $type): self |
|
| 198 | { |
|
| 199 | $this->type = $type->getValue(); |
|
| 200 | ||
| 201 | return $this; |
|
| 202 | } |
|
| 203 | } |
|
| 204 | ||