
* model changes * Endpoint to get all avaible booking rooms per summit GET /api/v1/summits/{id}/locations/bookable-rooms query string params page ( int ) current page number per_page ( int) max amount of items per page filter ( allowed fields: name, description, cost, capacity, availability_day[epoch], attribute[string|number]) order ( allowed fields id,name,capacity) expand ( allowed relations venue,floor,attribute_type) scopes %s/bookable-rooms/read %s/summits/read/all * Endpoint to get slot availability per room GET /api/v1/summits/{id}/locations/bookable-rooms/{room_id}/availability/{day} where id is summit id (integer) room_id ( integer) and day (epoch timestamp) scopes %s/bookable-rooms/read %s/summits/read/all * endpoint create reservation POST /api/v1/summits/{id}/locations/bookable-rooms/{room_id}/reservations payload 'currency' => 'required|string|currency_iso', 'amount' => 'required|integer', 'start_datetime' => 'required|date_format:U', 'end_datetime' => 'required|date_format:U|after:start_datetime', scopes %s/bookable-rooms/my-reservations/write * endpoint to get all my reservations GET /api/v1/summits/{id}/locations/bookable-rooms/all/reservations/me query string params expand [owner, room, type] scopes %s/bookable-rooms/my-reservations/read * endpoint to cancel/ask for refund a reservation DELETE /api/v1/summits/{id}/locations/bookable-rooms/all/reservations/{reservation_id} scopes %s/bookable-rooms/my-reservations/write Change-Id: I741878c6ffc833ba23fca40f09f4664b42c8edd4
192 lines
5.1 KiB
PHP
192 lines
5.1 KiB
PHP
<?php namespace models\summit;
|
|
/**
|
|
* Copyright 2015 OpenStack Foundation
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
**/
|
|
use App\Models\Foundation\Main\OrderableChilds;
|
|
use Doctrine\Common\Collections\Criteria;
|
|
use Doctrine\ORM\Mapping AS ORM;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use models\exceptions\ValidationException;
|
|
/**
|
|
* @ORM\Entity
|
|
* @ORM\Table(name="SummitVenue")
|
|
* Class SummitVenue
|
|
* @package models\summit
|
|
*/
|
|
class SummitVenue extends SummitGeoLocatedLocation
|
|
{
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getClassName(){
|
|
return self::ClassName;
|
|
}
|
|
|
|
const ClassName = 'SummitVenue';
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->is_main = false;
|
|
$this->type = self::TypeInternal;
|
|
$this->rooms = new ArrayCollection();
|
|
$this->floors = new ArrayCollection();
|
|
}
|
|
|
|
/**
|
|
* @ORM\Column(name="IsMain", type="boolean")
|
|
* @var bool
|
|
*/
|
|
private $is_main;
|
|
|
|
/**
|
|
* @ORM\OneToMany(targetEntity="models\summit\SummitVenueRoom", mappedBy="venue", cascade={"persist"}, orphanRemoval=true)
|
|
* @var SummitVenueRoom[]
|
|
*/
|
|
private $rooms;
|
|
|
|
/**
|
|
* @ORM\OneToMany(targetEntity="models\summit\SummitVenueFloor", mappedBy="venue", cascade={"persist"}, orphanRemoval=true)
|
|
* @var SummitVenueFloor[]
|
|
*/
|
|
private $floors;
|
|
|
|
public function addFloor(SummitVenueFloor $floor){
|
|
$this->floors->add($floor);
|
|
$floor->setVenue($this);
|
|
}
|
|
|
|
public function addRoom(SummitVenueRoom $room){
|
|
$this->rooms->add($room);
|
|
$room->setVenue($this);
|
|
}
|
|
|
|
use OrderableChilds;
|
|
|
|
/**
|
|
* @param SummitVenueRoom $room
|
|
* @param int $new_order
|
|
* @throws ValidationException
|
|
*/
|
|
public function recalculateRoomsOrder(SummitVenueRoom $room, $new_order){
|
|
self::recalculateOrderForSelectable($this->rooms, $room, $new_order);
|
|
}
|
|
|
|
/**
|
|
* @return bool
|
|
*/
|
|
public function getIsMain()
|
|
{
|
|
return (bool)$this->is_main;
|
|
}
|
|
|
|
/**
|
|
* @param bool $is_main
|
|
*/
|
|
public function setIsMain($is_main)
|
|
{
|
|
$this->is_main = $is_main;
|
|
}
|
|
|
|
/**
|
|
* @return SummitVenueRoom[]
|
|
*/
|
|
public function getRooms(){
|
|
return $this->rooms;
|
|
}
|
|
|
|
/**
|
|
* @param int $room_id
|
|
* @return SummitVenueRoom|null
|
|
*/
|
|
public function getRoom($room_id){
|
|
$criteria = Criteria::create();
|
|
$criteria->where(Criteria::expr()->eq('id', intval($room_id)));
|
|
$room = $this->rooms->matching($criteria)->first();
|
|
return $room === false ? null : $room;
|
|
}
|
|
|
|
/**
|
|
* @return SummitVenueFloor[]
|
|
*/
|
|
public function getFloors(){
|
|
return $this->floors;
|
|
}
|
|
|
|
/**
|
|
* @param int $floor_id
|
|
* @return SummitVenueFloor|null
|
|
*/
|
|
public function getFloor($floor_id){
|
|
$criteria = Criteria::create();
|
|
$criteria->where(Criteria::expr()->eq('id', intval($floor_id)));
|
|
$floor = $this->floors->matching($criteria)->first();
|
|
return $floor === false ? null:$floor;
|
|
}
|
|
|
|
|
|
public static $metadata = [
|
|
'class_name' => self::ClassName,
|
|
'is_main' => 'boolean',
|
|
'floors' => 'array',
|
|
'rooms' => 'array',
|
|
];
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public static function getMetadata(){
|
|
return array_merge(SummitGeoLocatedLocation::getMetadata(), self::$metadata);
|
|
}
|
|
|
|
/**
|
|
* @param string $floor_name
|
|
* @return SummitVenueFloor|null
|
|
*/
|
|
public function getFloorByName($floor_name){
|
|
$criteria = Criteria::create();
|
|
$criteria->where(Criteria::expr()->eq('name', trim($floor_name)));
|
|
$floor = $this->floors->matching($criteria)->first();
|
|
return $floor === false ? null : $floor;
|
|
}
|
|
|
|
/**
|
|
* @param int $floor_number
|
|
* @return SummitVenueFloor|null
|
|
*/
|
|
public function getFloorByNumber($floor_number){
|
|
$criteria = Criteria::create();
|
|
$criteria->where(Criteria::expr()->eq('number', intval($floor_number)));
|
|
$floor = $this->floors->matching($criteria)->first();
|
|
return $floor === false ? null:$floor;
|
|
}
|
|
|
|
/**
|
|
* @param SummitVenueFloor $floor
|
|
* @return $this
|
|
*/
|
|
public function removeFloor(SummitVenueFloor $floor){
|
|
$this->floors->removeElement($floor);
|
|
$floor->clearVenue();
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @param SummitVenueRoom $room
|
|
* @return $this
|
|
*/
|
|
public function removeRoom(SummitVenueRoom $room){
|
|
$this->rooms->removeElement($room);
|
|
$room->clearVenue();
|
|
return $this;
|
|
}
|
|
} |