auth()->user()->email, 'eventAccount' => $this->tenant->account_name, 'eventIban' => $this->tenant->account_iban, 'eventPayPerDay' => $this->tenant->slug === 'lv' ? true : false, 'participationFeeType' => $this->tenant->slug === 'lv' ? ParticipationFeeType::PARTICIPATION_FEE_TYPE_FIXED : ParticipationFeeType::PARTICIPATION_FEE_TYPE_SOLIDARITY, ])->render(); } public function doCreate(Request $request) : JsonResponse { $eventBegin = DateTime::createFromFormat('Y-m-d', $request->input('eventBegin')); $eventEnd = DateTime::createFromFormat('Y-m-d', $request->input('eventEnd')); $eventEarlyBirdEnd = DateTime::createFromFormat('Y-m-d', $request->input('eventEarlyBirdEnd')); $registrationFinalEnd = DateTime::createFromFormat('Y-m-d', $request->input('eventRegistrationFinalEnd')); $participationFeeType = ParticipationFeeType::where('slug', $request->input('eventParticipationFeeType'))->first(); $payPerDay = $request->input('eventPayPerDay'); $payDirect = $request->input('eventPayDirectly'); $billingDeadline = $eventEnd->modify('+1 month'); $createRequest = new CreateEventRequest( $request->input('eventName'), $request->input('eventLocation'), $request->input('eventPostalCode'), $request->input('eventEmail'), $eventBegin, $eventEnd, $eventEarlyBirdEnd, $registrationFinalEnd, $request->input('eventEarlyBirdEndAmountIncrease'), $participationFeeType, $request->input('eventAccount'), $request->input('eventIban'), $payPerDay, $payDirect ); $wasSuccessful = false; $createCommand = new CreateEventCommand($createRequest); $result = $createCommand->execute(); if ($result->success) { $createCostUnitRequest = new CreateCostUnitRequest( $result->event->name, CostUnitType::COST_UNIT_TYPE_EVENT, Amount::fromString('0,25'), true, $billingDeadline ); $createCostUnitCommand = new CreateCostUnitCommand($createCostUnitRequest); $costUnitResponse = $createCostUnitCommand->execute(); if ($costUnitResponse->success) { $costUnitUpdateRequest = new SetCostUnitRequest($result->event, $costUnitResponse->costUnit); $costUnitUpdateCommand = new SetCostUnitCommand($costUnitUpdateRequest); $costUnitSetResponse = $costUnitUpdateCommand->execute(); $wasSuccessful = $costUnitSetResponse->success; } } if ($wasSuccessful) { return response()->json([ 'status' => 'success', 'event' => new EventResource($costUnitUpdateRequest->event)->toArray() ]); } else { return response()->json([ 'status' => 'error', 'message' => 'Die Veranstaltung konnte nicht angelegt werden.' ]); } } }