Skip to content

Commit f404eba

Browse files
committed
Feature: Add per-event setting to hide the checkout "Copy to all attendees" option
1 parent 347ee48 commit f404eba

16 files changed

Lines changed: 250 additions & 2 deletions

File tree

backend/app/DomainObjects/Generated/EventSettingDomainObjectAbstract.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ abstract class EventSettingDomainObjectAbstract extends \HiEvents\DomainObjects\
6161
final public const TICKET_DESIGN_SETTINGS = 'ticket_design_settings';
6262
final public const ATTENDEE_DETAILS_COLLECTION_METHOD = 'attendee_details_collection_method';
6363
final public const SHOW_MARKETING_OPT_IN = 'show_marketing_opt_in';
64+
final public const ALLOW_COPY_DETAILS_TO_ALL_ATTENDEES = 'allow_copy_details_to_all_attendees';
6465
final public const HOMEPAGE_THEME_SETTINGS = 'homepage_theme_settings';
6566
final public const PASS_PLATFORM_FEE_TO_BUYER = 'pass_platform_fee_to_buyer';
6667
final public const ALLOW_ATTENDEE_SELF_EDIT = 'allow_attendee_self_edit';
@@ -119,6 +120,7 @@ abstract class EventSettingDomainObjectAbstract extends \HiEvents\DomainObjects\
119120
protected array|string|null $ticket_design_settings = null;
120121
protected string $attendee_details_collection_method = 'PER_TICKET';
121122
protected bool $show_marketing_opt_in = true;
123+
protected bool $allow_copy_details_to_all_attendees = true;
122124
protected array|string|null $homepage_theme_settings = null;
123125
protected bool $pass_platform_fee_to_buyer = false;
124126
protected bool $allow_attendee_self_edit = true;
@@ -180,6 +182,7 @@ public function toArray(): array
180182
'ticket_design_settings' => $this->ticket_design_settings ?? null,
181183
'attendee_details_collection_method' => $this->attendee_details_collection_method ?? null,
182184
'show_marketing_opt_in' => $this->show_marketing_opt_in ?? null,
185+
'allow_copy_details_to_all_attendees' => $this->allow_copy_details_to_all_attendees ?? null,
183186
'homepage_theme_settings' => $this->homepage_theme_settings ?? null,
184187
'pass_platform_fee_to_buyer' => $this->pass_platform_fee_to_buyer ?? null,
185188
'allow_attendee_self_edit' => $this->allow_attendee_self_edit ?? null,
@@ -751,6 +754,17 @@ public function getShowMarketingOptIn(): bool
751754
return $this->show_marketing_opt_in;
752755
}
753756

757+
public function setAllowCopyDetailsToAllAttendees(bool $allow_copy_details_to_all_attendees): self
758+
{
759+
$this->allow_copy_details_to_all_attendees = $allow_copy_details_to_all_attendees;
760+
return $this;
761+
}
762+
763+
public function getAllowCopyDetailsToAllAttendees(): bool
764+
{
765+
return $this->allow_copy_details_to_all_attendees;
766+
}
767+
754768
public function setHomepageThemeSettings(array|string|null $homepage_theme_settings): self
755769
{
756770
$this->homepage_theme_settings = $homepage_theme_settings;

backend/app/Http/Request/EventSettings/UpdateEventSettingsRequest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ public function rules(): array
9292
// Marketing settings
9393
'show_marketing_opt_in' => ['boolean'],
9494

95+
// Attendee detail copy control
96+
'allow_copy_details_to_all_attendees' => ['boolean'],
97+
9598
// Platform fee settings
9699
'pass_platform_fee_to_buyer' => ['boolean'],
97100

backend/app/Resources/Event/EventSettingsResource.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ public function toArray($request): array
7171
// Marketing settings
7272
'show_marketing_opt_in' => $this->getShowMarketingOptIn(),
7373

74+
// Attendee detail copy control
75+
'allow_copy_details_to_all_attendees' => $this->getAllowCopyDetailsToAllAttendees(),
76+
7477
// Platform fee settings
7578
'pass_platform_fee_to_buyer' => $this->getPassPlatformFeeToBuyer(),
7679

backend/app/Resources/Event/EventSettingsResourcePublic.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ public function toArray($request): array
7777
// Marketing settings
7878
'show_marketing_opt_in' => $this->getShowMarketingOptIn(),
7979

80+
// Attendee detail copy control
81+
'allow_copy_details_to_all_attendees' => $this->getAllowCopyDetailsToAllAttendees(),
82+
8083
// Platform fee settings
8184
'pass_platform_fee_to_buyer' => $this->getPassPlatformFeeToBuyer(),
8285

backend/app/Services/Application/Handlers/EventSettings/DTO/UpdateEventSettingsDTO.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ public function __construct(
7676
// Marketing settings
7777
public readonly bool $show_marketing_opt_in = true,
7878

79+
// Attendee detail copy control
80+
public readonly bool $allow_copy_details_to_all_attendees = true,
81+
7982
// Platform fee settings
8083
public readonly bool $pass_platform_fee_to_buyer = false,
8184

@@ -158,6 +161,9 @@ public static function createWithDefaults(
158161
// Marketing defaults
159162
show_marketing_opt_in: true,
160163

164+
// Attendee detail copy control default
165+
allow_copy_details_to_all_attendees: true,
166+
161167
// Platform fee defaults
162168
pass_platform_fee_to_buyer: false,
163169

backend/app/Services/Application/Handlers/EventSettings/PartialUpdateEventSettingsHandler.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ public function handle(PartialUpdateEventSettingsDTO $eventSettingsDTO): EventSe
127127
// Marketing settings
128128
'show_marketing_opt_in' => $eventSettingsDTO->settings['show_marketing_opt_in'] ?? $existingSettings->getShowMarketingOptIn(),
129129

130+
// Attendee detail copy control
131+
'allow_copy_details_to_all_attendees' => $eventSettingsDTO->settings['allow_copy_details_to_all_attendees'] ?? $existingSettings->getAllowCopyDetailsToAllAttendees(),
132+
130133
// Platform fee settings
131134
'pass_platform_fee_to_buyer' => $eventSettingsDTO->settings['pass_platform_fee_to_buyer'] ?? $existingSettings->getPassPlatformFeeToBuyer(),
132135

backend/app/Services/Application/Handlers/EventSettings/UpdateEventSettingsHandler.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ public function handle(UpdateEventSettingsDTO $settings): EventSettingDomainObje
8989
// Marketing settings
9090
'show_marketing_opt_in' => $settings->show_marketing_opt_in,
9191

92+
// Attendee detail copy control
93+
'allow_copy_details_to_all_attendees' => $settings->allow_copy_details_to_all_attendees,
94+
9295
// Platform fee settings
9396
'pass_platform_fee_to_buyer' => $settings->pass_platform_fee_to_buyer,
9497

backend/app/Services/Domain/Event/CreateEventService.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ private function createEventSettings(
226226

227227
'attendee_details_collection_method' => $organizerSettings->getDefaultAttendeeDetailsCollectionMethod(),
228228
'show_marketing_opt_in' => $organizerSettings->getDefaultShowMarketingOptIn(),
229+
'allow_copy_details_to_all_attendees' => true,
229230
'pass_platform_fee_to_buyer' => $organizerSettings->getDefaultPassPlatformFeeToBuyer(),
230231
'allow_attendee_self_edit' => $organizerSettings->getDefaultAllowAttendeeSelfEdit() ?? false,
231232
'ticket_design_settings' => [
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
public function up(): void
10+
{
11+
Schema::table('event_settings', function (Blueprint $table) {
12+
$table->boolean('allow_copy_details_to_all_attendees')->default(true)->after('show_marketing_opt_in');
13+
});
14+
}
15+
16+
public function down(): void
17+
{
18+
Schema::table('event_settings', function (Blueprint $table) {
19+
$table->dropColumn('allow_copy_details_to_all_attendees');
20+
});
21+
}
22+
};

backend/tests/Unit/Http/Request/EventSettings/UpdateEventSettingsRequestTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,34 @@ public function test_date_display_mode_is_optional(): void
4343

4444
$this->assertFalse($validator->errors()->has('ticket_design_settings.date_display_mode'));
4545
}
46+
47+
public function test_allow_copy_details_to_all_attendees_accepts_boolean(): void
48+
{
49+
$validator = Validator::make(
50+
['allow_copy_details_to_all_attendees' => false],
51+
(new UpdateEventSettingsRequest)->rules()
52+
);
53+
54+
$this->assertFalse($validator->errors()->has('allow_copy_details_to_all_attendees'));
55+
}
56+
57+
public function test_allow_copy_details_to_all_attendees_rejects_non_boolean(): void
58+
{
59+
$validator = Validator::make(
60+
['allow_copy_details_to_all_attendees' => 'not-a-boolean'],
61+
(new UpdateEventSettingsRequest)->rules()
62+
);
63+
64+
$this->assertTrue($validator->errors()->has('allow_copy_details_to_all_attendees'));
65+
}
66+
67+
public function test_allow_copy_details_to_all_attendees_is_optional(): void
68+
{
69+
$validator = Validator::make(
70+
['ticket_design_settings' => ['accent_color' => '#333333']],
71+
(new UpdateEventSettingsRequest)->rules()
72+
);
73+
74+
$this->assertFalse($validator->errors()->has('allow_copy_details_to_all_attendees'));
75+
}
4676
}

0 commit comments

Comments
 (0)