From 17f8f50866d84d761784529cbd57a7ceb9b5785b Mon Sep 17 00:00:00 2001 From: philipp lang Date: Sat, 7 Jan 2023 18:13:03 +0100 Subject: [PATCH] Add thanks --- assets/eventregistration.js | 4 + components/EventForm.php | 8 +- components/eventform/default.htm | 127 ++++---------------------- models/Participant.php | 2 +- updates/create_participants_table.php | 2 +- 5 files changed, 32 insertions(+), 111 deletions(-) diff --git a/assets/eventregistration.js b/assets/eventregistration.js index 7beae15..dbe6ef0 100644 --- a/assets/eventregistration.js +++ b/assets/eventregistration.js @@ -33,6 +33,7 @@ export default function (toasted) { vorteam: null, }, meta: { + finished: true, submitRequest: null, errorFields: [], active: 2, @@ -123,6 +124,9 @@ export default function (toasted) { }); }); } + if (response.status === 201) { + _self.meta.finished = true; + } }); }, scrollToFirstError(errors) { diff --git a/components/EventForm.php b/components/EventForm.php index 5c38c72..a476b95 100644 --- a/components/EventForm.php +++ b/components/EventForm.php @@ -7,6 +7,7 @@ use Illuminate\Http\JsonResponse; use Illuminate\Support\Facades\Lang; use Input; use Winter\Storm\Support\Facades\Validator; +use Zoomyboy\Event\Models\Participant; class EventForm extends ComponentBase { @@ -57,7 +58,10 @@ class EventForm extends ComponentBase return response()->json($validator->errors(), 422); } - $fields = $validator->validated(); - dd($fields); + Participant::create(array_merge($validator->validated(), [ + 'vorteam' => 'Ja' === Input::get('vorteam'), + ])); + + return response()->json([], 201); } } diff --git a/components/eventform/default.htm b/components/eventform/default.htm index b5a53ac..d420e50 100644 --- a/components/eventform/default.htm +++ b/components/eventform/default.htm @@ -97,7 +97,7 @@ {#+++ registrationForm +++#}
-
+
{% set arrowClass = "flex flex-col md:flex-row items-center justify-center md:justify-start px-2 flex-auto md:pl-6 h-12 md:h-16 transition duration-300" %} {% set positionClass = "flex items-center justify-center w-4 md:w-6 h-4 md:h-6 rounded-full bg-teal-800 text-teal-200 font-goudy transition duration-300" %} {% set arrowFont = "text-sm text-teal-100" %} @@ -198,116 +198,29 @@
- - -
- - diff --git a/models/Participant.php b/models/Participant.php index cf75b49..4cf5b49 100644 --- a/models/Participant.php +++ b/models/Participant.php @@ -39,7 +39,7 @@ class Participant extends Model /** * @var array Attributes to be cast to JSON */ - protected $jsonable = []; + protected $jsonable = ['food_preferences']; /** * @var array Attributes to be appended to the API representation of the model (ex. toArray()) diff --git a/updates/create_participants_table.php b/updates/create_participants_table.php index 21c6cfc..d9d6567 100644 --- a/updates/create_participants_table.php +++ b/updates/create_participants_table.php @@ -21,7 +21,7 @@ class CreateParticipantsTable extends Migration $table->string('group')->nullable(); $table->string('agegroup'); $table->string('agegroup_leader'); - $table->boolean('vorteam'); + $table->boolean('vorteam')->default(false); $table->boolean('foto'); $table->string('emergency_phone'); $table->string('address');