public function testDelete() { $this->resetRoomDetailsTable(); $roomDetails = new RoomDetails(); $roomDetails->setAttributes(array('roomid' => 1, 'description' => 'A single room with sea views')); $roomDetails->save(); $this->assertTrue($roomDetails->delete()); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new RoomDetails(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['RoomDetails'])) { $model->attributes = $_POST['RoomDetails']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new RoomDetails(); $room = Room::model()->findByAttributes(array('room_no' => $_REQUEST['id'])); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); $cnt = ''; if (isset($_POST['RoomDetails'])) { $roomdetails = RoomDetails::model()->findAllByAttributes(array('room_no' => $_POST['RoomDetails']['room_no'])); $cnt = count($roomdetails); if ($cnt < $room->no_of_bed) { $model->attributes = $_POST['RoomDetails']; $model->status = 'C'; if ($model->save()) { //$this->redirect(array('/RoomDetails/create/','id'=>$room->id)); $this->redirect(array('view', 'id' => $model->id)); } $cnt++; } else { $this->redirect(array('/Room/error/')); } } $this->render('create', array('model' => $model)); }