Skip to content

Commit 82b5491

Browse files
committed
Add ability to add notes to attendees
1 parent 8041231 commit 82b5491

File tree

21 files changed

+298
-258
lines changed

21 files changed

+298
-258
lines changed

backend/app/DomainObjects/Generated/AttendeeDomainObjectAbstract.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ abstract class AttendeeDomainObjectAbstract extends \HiEvents\DomainObjects\Abst
2828
final public const UPDATED_AT = 'updated_at';
2929
final public const DELETED_AT = 'deleted_at';
3030
final public const LOCALE = 'locale';
31+
final public const NOTES = 'notes';
3132

3233
protected int $id;
3334
protected int $order_id;
@@ -47,6 +48,7 @@ abstract class AttendeeDomainObjectAbstract extends \HiEvents\DomainObjects\Abst
4748
protected string $updated_at;
4849
protected ?string $deleted_at = null;
4950
protected string $locale = 'en';
51+
protected ?string $notes = null;
5052

5153
public function toArray(): array
5254
{
@@ -69,6 +71,7 @@ public function toArray(): array
6971
'updated_at' => $this->updated_at ?? null,
7072
'deleted_at' => $this->deleted_at ?? null,
7173
'locale' => $this->locale ?? null,
74+
'notes' => $this->notes ?? null,
7275
];
7376
}
7477

@@ -269,4 +272,15 @@ public function getLocale(): string
269272
{
270273
return $this->locale;
271274
}
275+
276+
public function setNotes(?string $notes): self
277+
{
278+
$this->notes = $notes;
279+
return $this;
280+
}
281+
282+
public function getNotes(): ?string
283+
{
284+
return $this->notes;
285+
}
272286
}

backend/app/Http/Actions/Attendees/EditAttendeeAction.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public function __invoke(EditAttendeeRequest $request, int $eventId, int $attend
3737
'product_price_id' => $request->input('product_price_id'),
3838
'event_id' => $eventId,
3939
'attendee_id' => $attendeeId,
40+
'notes' => $request->input('notes'),
4041
]));
4142
} catch (NoTicketsAvailableException $exception) {
4243
throw ValidationException::withMessages([

backend/app/Http/Request/Attendee/EditAttendeeRequest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public function rules(): array
1515
'last_name' => RulesHelper::REQUIRED_STRING,
1616
'product_id' => RulesHelper::REQUIRED_NUMERIC,
1717
'product_price_id' => RulesHelper::REQUIRED_NUMERIC,
18+
'notes' => RulesHelper::OPTIONAL_TEXT_MEDIUM_LENGTH,
1819
];
1920
}
2021

@@ -29,6 +30,7 @@ public function messages(): array
2930
'product_price_id.required' => __('Product price is required'),
3031
'product_id.numeric' => '',
3132
'product_price_id.numeric' => '',
33+
'notes.max' => __('Notes must be less than 2000 characters'),
3234
];
3335
}
3436
}

backend/app/Http/Request/ProductCategory/UpsertProductCategoryRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public function rules(): array
1212
'name' => ['string', 'required', 'max:50'],
1313
'description' => ['string', 'max:255', 'nullable'],
1414
'is_hidden' => ['boolean', 'required'],
15-
'no_products_message' => ['string', 'max:255', 'required'],
15+
'no_products_message' => ['string', 'max:255', 'nullable'],
1616
];
1717
}
1818
}

backend/app/Resources/Attendee/AttendeeResource.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public function toArray(Request $request): array
3030
'public_id' => $this->getPublicId(),
3131
'short_id' => $this->getShortId(),
3232
'locale' => $this->getLocale(),
33+
'notes' => $this->getNotes(),
3334
'product' => $this->when(
3435
!is_null($this->getProduct()),
3536
fn() => new ProductResource($this->getProduct()),

backend/app/Services/Application/Handlers/Attendee/DTO/EditAttendeeDTO.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
class EditAttendeeDTO extends BaseDTO
88
{
99
public function __construct(
10-
public string $first_name,
11-
public string $last_name,
12-
public string $email,
13-
public int $product_id,
14-
public int $product_price_id,
15-
public int $event_id,
16-
public int $attendee_id,
10+
public string $first_name,
11+
public string $last_name,
12+
public string $email,
13+
public int $product_id,
14+
public int $product_price_id,
15+
public int $event_id,
16+
public int $attendee_id,
17+
public ?string $notes = null,
1718
)
1819
{
1920
}

backend/app/Services/Application/Handlers/Attendee/EditAttendeeHandler.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use HiEvents\DomainObjects\Enums\ProductPriceType;
77
use HiEvents\DomainObjects\Generated\AttendeeDomainObjectAbstract;
88
use HiEvents\DomainObjects\Generated\ProductDomainObjectAbstract;
9+
use HiEvents\DomainObjects\ProductDomainObject;
910
use HiEvents\DomainObjects\ProductPriceDomainObject;
1011
use HiEvents\Exceptions\NoTicketsAvailableException;
1112
use HiEvents\Repository\Interfaces\AttendeeRepositoryInterface;
@@ -59,6 +60,7 @@ private function updateAttendee(EditAttendeeDTO $editAttendeeDTO): AttendeeDomai
5960
'last_name' => $editAttendeeDTO->last_name,
6061
'email' => $editAttendeeDTO->email,
6162
'product_id' => $editAttendeeDTO->product_id,
63+
'notes' => $editAttendeeDTO->notes,
6264
], [
6365
'event_id' => $editAttendeeDTO->event_id,
6466
]);
@@ -70,6 +72,7 @@ private function updateAttendee(EditAttendeeDTO $editAttendeeDTO): AttendeeDomai
7072
*/
7173
private function validateProductId(EditAttendeeDTO $editAttendeeDTO): void
7274
{
75+
/** @var ProductDomainObject $product */
7376
$product = $this->productRepository
7477
->loadRelation(ProductPriceDomainObject::class)
7578
->findFirstWhere([

backend/app/Services/Application/Handlers/ProductCategory/CreateProductCategoryHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function handle(UpsertProductCategoryDTO $dto): ProductCategoryDomainObje
2121
isHidden: $dto->is_hidden,
2222
eventId: $dto->event_id,
2323
description: $dto->description,
24-
noProductsMessage: $dto->no_products_message,
24+
noProductsMessage: $dto->no_products_message ?? __('There are no products available in this category'),
2525
);
2626
}
2727
}

backend/app/Services/Application/Handlers/ProductCategory/EditProductCategoryHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function handle(UpsertProductCategoryDTO $dto): ProductCategoryDomainObje
2121
'name' => $dto->name,
2222
'is_hidden' => $dto->is_hidden,
2323
'description' => $dto->description,
24-
'no_products_message' => $dto->no_products_message,
24+
'no_products_message' => $dto->no_products_message ?? __('There are no products available in this category'),
2525
],
2626
where: [
2727
'id' => $dto->product_category_id,

backend/app/Validators/Rules/RulesHelper.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ class RulesHelper
1616

1717
public const REQUIRED_EMAIL = ['email' , 'required', 'max:100'];
1818

19+
public const OPTIONAL_TEXT_MEDIUM_LENGTH = ['string', 'max:2000', 'nullable'];
1920
}

0 commit comments

Comments
 (0)