PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.7
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.7
6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 All 196 releases
fluentform / app / Http / Controllers / FormSettingsController.php

FormSettingsController.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 6.2.7, at app/Http/Controllers/FormSettingsController.php

169 lines 5.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentForm\App\Http\Controllers;
4
5 use Exception;
6 use FluentForm\App\Services\Settings\Customizer;
7 use FluentForm\App\Services\Settings\SettingsService;
8 use FluentForm\Framework\Validator\ValidationException;
9 use FluentForm\App\Services\Submission\SubmissionService;
10
11 class FormSettingsController extends Controller
12 {
13 public function index(SettingsService $settingsService, $formId)
14 {
15 $attributes = $this->request->all();
16 $attributes['form_id'] = (int) $formId;
17
18 $result = $settingsService->get($attributes);
19
20 return $this->sendSuccess($result);
21 }
22
23 public function general(SettingsService $settingsService, $formId)
24 {
25 $result = $settingsService->general($formId);
26
27 return $this->sendSuccess($result);
28 }
29
30 public function saveGeneral(SettingsService $settingsService, $formId)
31 {
32 try {
33 $attributes = $this->request->all();
34 $attributes['form_id'] = (int) $formId;
35
36 $settingsService->saveGeneral($attributes);
37
38 return $this->sendSuccess([
39 'message' => __('Settings has been saved.', 'fluentform'),
40 ]);
41 } catch (ValidationException $exception) {
42 return $this->sendError($exception->errors(), 422);
43 }
44 }
45
46 public function store(SettingsService $settingsService, $formId)
47 {
48 try {
49 $attributes = $this->request->all();
50 $attributes['form_id'] = (int) $formId;
51
52 [$settingsId, $settings] = $settingsService->store($attributes);
53
54 return $this->sendSuccess([
55 'message' => __('Settings has been saved.', 'fluentform'),
56 'id' => $settingsId,
57 'settings' => $settings,
58 ]);
59 } catch (ValidationException $exception) {
60 return $this->sendError($exception->errors(), 422);
61 }
62 }
63
64 public function remove(SettingsService $settingsService, $formId)
65 {
66 $attributes = $this->request->all();
67 $attributes['form_id'] = (int) $formId;
68
69 $settingsService->remove($attributes);
70
71 return $this->sendSuccess([]);
72 }
73
74 public function customizer(Customizer $customizer, $id)
75 {
76 $metaKeys = [
77 '_custom_form_css',
78 '_custom_form_js',
79 '_ff_selected_style',
80 '_ff_form_styles'
81 ];
82
83 return $this->sendSuccess($customizer->get($id, $metaKeys));
84 }
85
86 public function storeCustomizer(Customizer $customizer, $id)
87 {
88 try {
89 $attributes = $this->request->all();
90 $attributes['form_id'] = (int) $id;
91
92 $customizer->store($attributes);
93
94 return $this->sendSuccess([
95 'message' => __('Custom CSS & JS successfully saved.', 'fluentform'),
96 ]);
97 } catch (Exception $e) {
98 return $this->sendError([
99 'message' => $e->getMessage(),
100 ], 423);
101 }
102 }
103
104 public function storeEntryColumns(SubmissionService $submissionService, $id)
105 {
106 try {
107 $attributes = $this->request->all();
108 $attributes['form_id'] = (int) $id;
109
110 $submissionService->storeColumnSettings($attributes);
111
112 return $this->sendSuccess([
113 'message' => __('The column display order has been saved.', 'fluentform'),
114 ]);
115 } catch (Exception $e) {
116 return $this->sendError([
117 'message' => $e->getMessage(),
118 ], 423);
119 }
120 }
121
122 public function conversationalDesign(SettingsService $settingsService, $formId)
123 {
124 try {
125 return $this->sendSuccess($settingsService->conversationalDesign($formId));
126 } catch (Exception $e) {
127 return $this->sendError([
128 'message' => $e->getMessage(),
129 ], 423);
130 }
131 }
132
133 public function storeConversationalDesign(SettingsService $settingsService, $formId)
134 {
135 try {
136 return $this->sendSuccess($settingsService->storeConversationalDesign($this->request->all(), $formId));
137 } catch (Exception $e) {
138 return $this->sendError([
139 'message' => $e->getMessage(),
140 ], 423);
141 }
142 }
143
144 public function getPreset(SettingsService $settingsService, $formId)
145 {
146 try {
147 return $this->sendSuccess($settingsService->getPreset($formId));
148 } catch (Exception $e) {
149 return $this->sendError([
150 'message' => $e->getMessage(),
151 ], 423);
152 }
153 }
154
155 public function savePreset(SettingsService $settingsService, $formId)
156 {
157 try {
158 $attributes = $this->request->all();
159 $attributes['form_id'] = (int) $formId;
160
161 return $this->sendSuccess($settingsService->savePreset($attributes));
162 } catch (Exception $e) {
163 return $this->sendError([
164 'message' => $e->getMessage(),
165 ], 423);
166 }
167 }
168 }
169