本文整理汇总了PHP中Reservation::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Reservation::model方法的具体用法?PHP Reservation::model怎么用?PHP Reservation::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reservation
的用法示例。
在下文中一共展示了Reservation::model方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: populate
public function populate($roomType, $dates)
{
$this->roomType = $roomType;
foreach ($dates as $date) {
$criteria = new CDbCriteria();
$criteria->condition = ':date between dateFrom and dateTo
and roomid=:roomId
and confirmreservation=true';
$criteria->params = array(":date" => $date, ":roomId" => $this->roomType->id);
$result = Reservation::model()->findAll($criteria);
$this->reservations[$date] = $result;
}
}
示例2: testUpdate
/**
* Test we can update the reservation.
*/
public function testUpdate()
{
$this->resetReservationTable();
$this->resetDateTimes();
$reservation = new Reservation();
$reservation->setAttributes(array('roomid' => 1, 'datefrom' => $this->_dateOverlapFrom, 'numberofnights' => $this->_numberofnights));
$reservation->save(false);
$newDateTo = DateTime::createFromFormat('Y-m-d', $this->_dateOverlapToObj->format('Y-m-d'));
$newDateTo->add(new DateInterval('P10D'));
$reservation = Reservation::model()->findByPk($reservation->getAttribute('id'));
$reservation->setAttribute('dateto', $newDateTo->format('Y-m-d'));
$reservation->setAttribute('confirmreservation', true);
//must run validation rules
$this->assertTrue($reservation->save());
$reservation = Reservation::model()->findByPk($reservation->getAttribute('id'));
$this->assertEquals($newDateTo->format('Y-m-d'), $reservation->dateto);
}
示例3: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'payment' page.
*/
public function actionCreate()
{
$model = new ReservationDetails();
$model->reservation = Reservation::model()->findByPk(Yii::app()->session['reservationid']);
$model->reservation->setAttribute('confirmreservation', true);
if (isset($_POST['ReservationDetails'])) {
if ($model->reservation->save()) {
$model->attributes = $_POST['ReservationDetails'];
$model->setAttribute('reservationid', $model->reservation->id);
if ($model->save()) {
if (!Yii::app()->user->isGuest) {
$this->redirect(array('reservation/update', 'id' => $model->reservation->id));
} else {
$this->redirect(array('viewPayment'));
}
}
} else {
throw new CHttpException(500, 'Unable to save reservation');
}
}
$this->render('create', array('model' => $model));
}
示例4: actionCancel
public function actionCancel($id)
{
$reservation = Reservation::model()->findByPk($id);
if (isset($reservation)) {
$reservation->status = 'CANCELED';
$reservation->save();
}
$this->redirect(Yii::app()->request->getBaseUrl(true) . '#cuenta');
}
示例5: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer the ID of the model to be loaded
*/
public function loadModel($id)
{
$model = Reservation::model()->findByPk((int) $id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}