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 +++#}
- - 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');