-
-
Notifications
You must be signed in to change notification settings - Fork 635
Expand file tree
/
Copy pathUpdateEventSettingsHandler.php
More file actions
116 lines (100 loc) · 6.46 KB
/
UpdateEventSettingsHandler.php
File metadata and controls
116 lines (100 loc) · 6.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
namespace HiEvents\Services\Application\Handlers\EventSettings;
use HiEvents\DomainObjects\EventSettingDomainObject;
use HiEvents\Repository\Interfaces\EventSettingsRepositoryInterface;
use HiEvents\Services\Application\Handlers\EventSettings\DTO\UpdateEventSettingsDTO;
use HiEvents\Services\Infrastructure\HtmlPurifier\HtmlPurifierService;
use Illuminate\Database\DatabaseManager;
use Throwable;
class UpdateEventSettingsHandler
{
public function __construct(
private readonly EventSettingsRepositoryInterface $eventSettingsRepository,
private readonly HtmlPurifierService $purifier,
private readonly DatabaseManager $databaseManager,
)
{
}
/**
* @throws Throwable
*/
public function handle(UpdateEventSettingsDTO $settings): EventSettingDomainObject
{
return $this->databaseManager->transaction(function () use ($settings) {
$this->eventSettingsRepository->updateWhere(
attributes: [
'post_checkout_message' => $settings->post_checkout_message
?? $this->purifier->purify($settings->post_checkout_message),
'pre_checkout_message' => $settings->pre_checkout_message
?? $this->purifier->purify($settings->pre_checkout_message),
'email_footer_message' => $settings->email_footer_message
?? $this->purifier->purify($settings->email_footer_message),
'support_email' => $settings->support_email,
'require_attendee_details' => $settings->require_attendee_details,
'attendee_details_collection_method' => $settings->attendee_details_collection_method->name,
'continue_button_text' => trim($settings->continue_button_text),
'homepage_background_color' => $settings->homepage_background_color,
'homepage_primary_color' => $settings->homepage_primary_color,
'homepage_primary_text_color' => $settings->homepage_primary_text_color,
'homepage_secondary_color' => $settings->homepage_secondary_color,
'homepage_secondary_text_color' => $settings->homepage_secondary_text_color,
'homepage_body_background_color' => $settings->homepage_body_background_color,
'homepage_background_type' => $settings->homepage_background_type->name,
'order_timeout_in_minutes' => $settings->order_timeout_in_minutes,
'website_url' => trim($settings->website_url),
'maps_url' => trim($settings->maps_url),
'location_details' => $settings->location_details?->toArray(),
'is_online_event' => $settings->is_online_event,
'online_event_connection_details' => $settings->online_event_connection_details
?? $this->purifier->purify($settings->online_event_connection_details),
'seo_title' => $settings->seo_title,
'seo_description' => $settings->seo_description,
'seo_keywords' => $settings->seo_keywords,
'allow_search_engine_indexing' => $settings->allow_search_engine_indexing,
'notify_organizer_of_new_orders' => $settings->notify_organizer_of_new_orders,
'price_display_mode' => $settings->price_display_mode->name,
'hide_getting_started_page' => $settings->hide_getting_started_page,
// Payment settings
'payment_providers' => $settings->payment_providers,
'offline_payment_instructions' => $settings->offline_payment_instructions
?? $this->purifier->purify($settings->offline_payment_instructions),
'allow_orders_awaiting_offline_payment_to_check_in' => $settings->allow_orders_awaiting_offline_payment_to_check_in,
// Invoice settings
'enable_invoicing' => $settings->enable_invoicing,
'invoice_label' => trim($settings->invoice_label),
'invoice_prefix' => trim($settings->invoice_prefix),
'invoice_start_number' => $settings->invoice_start_number,
'require_billing_address' => $settings->require_billing_address,
'organization_name' => trim($settings->organization_name),
'organization_address' => $this->purifier->purify($settings->organization_address),
'invoice_tax_details' => $this->purifier->purify($settings->invoice_tax_details),
'invoice_notes' => $this->purifier->purify($settings->invoice_notes),
'invoice_payment_terms_days' => $settings->invoice_payment_terms_days,
// Ticket design settings
'ticket_design_settings' => $settings->ticket_design_settings,
// Marketing settings
'show_marketing_opt_in' => $settings->show_marketing_opt_in,
// Platform fee settings
'pass_platform_fee_to_buyer' => $settings->pass_platform_fee_to_buyer,
// Homepage theme settings
'homepage_theme_settings' => $settings->homepage_theme_settings,
// Self-service settings
'allow_attendee_self_edit' => $settings->allow_attendee_self_edit,
// External registration settings
'is_external_registration' => $settings->is_external_registration,
'external_registration_url' => $settings->external_registration_url ? trim($settings->external_registration_url) : null,
'external_registration_button_text' => $settings->external_registration_button_text ? trim($settings->external_registration_button_text) : null,
'external_registration_message' => $settings->external_registration_message,
'external_registration_host' => $settings->external_registration_host ? trim($settings->external_registration_host) : null,
],
where: [
'event_id' => $settings->event_id,
],
);
return $this->eventSettingsRepository
->findFirstWhere([
'event_id' => $settings->event_id,
]);
});
}
}