64 lines
1.8 KiB
PHP
64 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Library;
|
|
|
|
|
|
use App\SingleSeatsUser;
|
|
|
|
class SeatNamePrinter
|
|
{
|
|
private $singleSeat;
|
|
public function __construct($ssu)
|
|
{
|
|
if($ssu INSTANCEOF SingleSeatsUser)
|
|
$this->singleSeat = $ssu->singleSeat()->first();
|
|
else
|
|
$this->singleSeat = $ssu;
|
|
}
|
|
|
|
public function calcSeatName(){
|
|
if($this->singleSeat->seat->event->reservation->name === "Mit Tischwahl"){
|
|
//return "Tisch ".$this->singleSeat->x.", Platz ".$this->singleSeat->y;
|
|
return "Reihe ".(14-$this->singleSeat->x).", Platz ".$this->singleSeat->y;
|
|
}
|
|
if($this->hasSeatNumbering()){
|
|
return $this->getTextWithSeatNumbering();
|
|
}else{
|
|
return $this->getTextWithoutSeatNumbering();
|
|
}
|
|
}
|
|
|
|
|
|
private function isEventWithoutSeatNumbering() {
|
|
$reservationName = $this->singleSeat->seat()->first()->event()->first()->reservation()->first()->name;
|
|
return $reservationName == "Ohne Platzwahl";
|
|
}
|
|
|
|
private function isEventSilvesterSpecial(){
|
|
return $this->singleSeat->x === 0 && $this->singleSeat->y === 0;
|
|
}
|
|
|
|
private function hasSeatNumbering()
|
|
{
|
|
if($this->isEventWithoutSeatNumbering()){
|
|
return false;
|
|
}
|
|
if($this->isEventSilvesterSpecial()){
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private function getTextWithoutSeatNumbering()
|
|
{
|
|
if($this->isEventSilvesterSpecial()) return "Erdgeschoss / Tisch";
|
|
if($this->isEventWithoutSeatNumbering()) return "Freie Platzwahl";
|
|
}
|
|
|
|
private function getTextWithSeatNumbering()
|
|
{
|
|
$simpleSeatPlace = new FormatSeatWithNumbering($this->singleSeat->x, $this->singleSeat->y);
|
|
return $simpleSeatPlace->getText();
|
|
}
|
|
}
|