singleSeats()->get(); $seats = array(); $highestX = 0; $highestY = 0; foreach($singleSeats as $singleSeat){ $seats[$singleSeat->x][$singleSeat->y] = $singleSeat->category; if($singleSeat->x > $highestX) $highestX = $singleSeat->x; if($singleSeat->y > $highestY) $highestY = $singleSeat->y; } $ret = ""; for($i=1; $i<=$highestX; $i++){ for($j=1; $j<=$highestY; $j++){ if(isset($seats[$i][$j])) $ret .= $seats[$i][$j]; else $ret.="_"; } $ret.="\n"; } return($ret); } protected function seatAlreadyExists($seat, $x, $y){ return count($seat->singleSeats()->where("x","=",$x)->where("y","=", $y)->get()) > 0; } protected function updateSeatMap($seat) { $seatingUpdate = Request::all(); //insert new seats $seatMap = $seatingUpdate["seatMap"]; $x = 0; $y = 1; for ($i=0; $iseatAlreadyExists($seat, $y, $x) && $seatMap[$i] != "_") { $s = new SingleSeat; $s->x = $y; $s->y = $x; $s->category = $seatMap[$i] . ""; $s->seat()->associate($seat); $s->save(); } } } } } protected function isSomeKindOfReservation($event){ $reservationType = $event->reservation()->first()->name; //e.g. "Ohne Sitzplatz", ... return $reservationType == "Mit Platzwahl" || $reservationType == "Mit Tischwahl" || $reservationType == "Ohne Platzwahl"; } protected function hasSeatMap($newEvent){ $reservationType = $newEvent->reservation()->first()->name; //e.g. "Ohne Sitzplatz", ... return $reservationType == "Mit Platzwahl" || $reservationType == "Mit Tischwahl"; } }