request = Request::all(); $this->fixCurrencyVariations(); if(!isset($this->request["end_date"])){ $this->request["end_date"] = $this->request["start_date"]; } if(isset($this->request["payableWithCulturecard"])){ $this->request["payableWithCulturecard"] = 1; }else{ $this->request["payableWithCulturecard"] = 0; } if(isset($this->request["hide_externally"])){ $this->request["hide_externally"] = 1; }else{ $this->request["hide_externally"] = 0; } $newEvent = Event::create($this->request); $newEvent->shorttext=$this->request["shorttext"]; $this->handleConcessions($newEvent, $this->request); $newEvent->categories()->sync($this->request["cat"]); $this->handleImageUpload($newEvent); if($this->isSomeKindOfReservation($newEvent)){ $reservationType = $newEvent->reservation()->first()->name; if($reservationType == "Mit Tischwahl"){ $dates = array('2026-03-13','2026-03-14','2026-03-15','2026-03-18','2026-03-19'); //$dates = array('2025-12-21'); //$dates = array($this->request["start_date"]); $newEvent->start_date = $dates[0]; $newEvent->end_date = end($dates); $newEvent->save(); foreach ($dates as $day ){ $seat = new Seat; $seat->date = $day; $seat->event()->associate($newEvent); $seat->save(); $this->updateSeatMapWithTables($seat); } }else{ $begin = new DateTime( $this->request["start_date"] ); $end = new DateTime( $this->request["end_date"] ); date_add($end, date_interval_create_from_date_string('1 day')); $interval = DateInterval::createFromDateString('1 day'); $period = new DatePeriod($begin, $interval, $end); foreach ($period as $dt ){ $day = $dt->format('Y-m-d'); $seat = new Seat; $seat->date = $day; $seat->event()->associate($newEvent); $seat->save(); if($this->hasSeatMap($newEvent)){ $this->updateSeatMap($seat); }else{ $this->updateSeatMapNoSeat($seat, $this->request["amountSeats"]); } } } } \Session::flash('flash_message', 'Die Veranstaltung '.$newEvent["title"].' wurde erfolgreich erstellt.'); return redirect('admin/events'); } private function handleConcessions($event, $data){ $names = $data["concessionNames"]; $percs = $data["concessionPercs"]; for($i=0; $irequest[$priceCat]); $this->request[$priceCat] = str_replace(',', '.', $this->request[$priceCat]); $this->request[$priceCat] = str_replace('€', '', $this->request[$priceCat]); }else{ $this->request[$priceCat] = "0"; } } private function handleImageUpload($newEvent){ $image = $this->request["cropped_image"]; $fileName = time()."_".$image->getClientOriginalName(); $image->move("imgs/events",$fileName); $newEvent["image"] = $fileName; $newEvent->save(); } private function updateSeatMapNoSeat($seat, $amountSeats) { for($i=0; $i<$amountSeats; $i++){ $s = new SingleSeat; $s->x = 1; $s->y = $i+1; $s->category = "s"; $s->seat()->associate($seat); $s->save(); } } private function updateSeatMapWithTables($seat) { for($x = 9; $x <= 13; $x ++){ $cols = 20; for($y = 1; $y <= $cols; $y++){ $s = new SingleSeat; $s->x = $x; $s->y = $y; $s->category = 'a'; $s->seat()->associate($seat); $s->save(); } } // start sommertheater // for($x = 1; $x <= 13; $x ++){ // $cols = 16; // if ($x >= 12) { // $cols = 10; // }else if($x >= 11) { // $cols = 12; // } // for($y = 1; $y <= $cols; $y++){ // $s = new SingleSeat; // $s->x = $x; // $s->y = $y; // if($x <= 5){ // $s->category = 'b'; // } else{ // $s->category = 'a'; // } // $s->seat()->associate($seat); // $s->save(); // } // } } }