本文整理汇总了PHP中Booking::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Booking::save方法的具体用法?PHP Booking::save怎么用?PHP Booking::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Booking
的用法示例。
在下文中一共展示了Booking::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate($shipment_id = '')
{
$model = new Booking();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
$awb = '';
if (is_numeric($shipment_id)) {
$shipment = Shipment::model()->findByPk($shipment_id);
if ($shipment instanceof Shipment) {
$model->address = $shipment->shipper_address;
$model->city = $shipment->shipper_city;
$model->postal = $shipment->shipper_postal;
$model->country = $shipment->shipper_country;
$model->phone = $shipment->shipper_phone;
$model->shipment_id = $shipment->id;
$awb = $shipment->awb;
}
}
if (isset($_POST['Booking'])) {
$model->attributes = $_POST['Booking'];
$model->setAttribute('booking_code', dechex(time()));
if ($model->save()) {
if (!empty($model->shipment_id) || $model->shipment_id != '') {
$shipment->booking_id = $model->id;
$tes = $shipment->update();
}
Yii::app()->user->setFlash('success', 'Success to add new booking, ' . $model->booking_code);
$this->redirect(array('index'));
}
}
$this->render('create', array('model' => $model, 'awb' => $awb));
}
示例2: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Booking();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Booking'])) {
$model->attributes = $_POST['Booking'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->booking_id));
}
}
$this->render('create', array('model' => $model));
}
示例3: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$booking = new Booking();
$input = Input::all();
$booking->userId = Input::get('userId');
$booking->source = Input::get('source');
$booking->destination = Input::get('destination');
$booking->date = Input::get('date');
$booking->time = Input::get('time');
$booking->capacity = Input::get('capacity');
$booking->save();
return Response::json(array('code' => '200', 'info' => 'New booking has been created.', 'id' => $booking->id));
}
示例4: postCreate
public function postCreate()
{
$validator = Validator::make(Input::all(), Booking::$rules);
if ($validator->passes()) {
$booking = new Booking();
$booking->car_id = Input::get('car_id');
$booking->user_id = Auth::user()->id;
$booking->book_from = Input::get('pick_up_date');
$booking->book_to = Input::get('drop_off_date');
$booking->save();
return Redirect::to('bookings')->with('message', 'Your booking has sent to us. Thank you!');
}
return Redirect::back()->with('message', 'Something went wrong')->withErrors($validator)->withInput();
}
示例5: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store($id)
{
$listing = Listing::where('isPublic', '=', 1)->where('id', '=', $id)->first();
if (!$listing) {
throw new \Symfony\Component\Routing\Exception\ResourceNotFoundException();
}
$input = Input::all();
//return print_r($input,true);
$yesterday = \Carbon\Carbon::now('Australia/Sydney');
$yesterday = $yesterday->format('Y-m-d H:i:s');
// return $yesterday;
$rules = array('comments' => array('required', 'min:3'), 'user_phone' => array('required', 'min:9', 'max:30'), 'request_start_datetime' => array('required', 'date', 'dateformat: Y-m-d H:i:s', 'before: ' . $input['request_end_datetime']), 'request_end_datetime' => array('required', 'date', 'dateformat: Y-m-d H:i:s', 'after: ' . $yesterday));
$validator = Validator::make($input, $rules);
if ($validator->fails()) {
return Redirect::back()->withInput($input)->withErrors($validator);
}
$comments = $this->sanitizeStringAndParseMarkdown($input['comments']);
$authuser = Auth::user();
$name = $authuser->name;
$bookings = new Booking();
$bookings->user_id = $authuser->id;
$bookings->user_name = $name;
$bookings->listing_id = $id;
$bookings->user_phone = $input['user_phone'];
$bookings->request_start_datetime = $input['request_start_datetime'];
$bookings->request_end_datetime = $input['request_end_datetime'];
$bookings->status = "Booking request submitted. Awaiting Open Source Collaborative Consumption Marketplace review.";
$bookings->user_comments = $comments;
$bookings->space_owner_id = $listing->owner_id;
$address = $listing->address1 . ", " . $listing->suburb . ", " . $listing->city . " " . $listing->country;
$data = $input;
$data['address'] = $address;
$data['title'] = $listing->title;
$data['id'] = $id;
$data['type'] = $listing->space_type;
$data['user_name'] = $name;
$data['status'] = $bookings->status;
/* TODO: Make it email the user and space owner */
Mail::send("booking.mail.newbookingfounders", $data, function ($message) {
$message->to('founders@worldburrow.com')->subject('New booking on Open Source Collaborative Consumption Marketplace');
});
$email = Auth::user()->email;
Mail::send("booking.mail.newbookinguser", $data, function ($message) use($email) {
$message->to($email)->subject('Your new booking on Open Source Collaborative Consumption Marketplace!');
});
$bookings->save();
return Redirect::to('dashboard')->with('flash_message_good', "Your booking has been sent. We'll be in touch soon with confirmation or questions!");
}
示例6: stageEnterCredentials
public function stageEnterCredentials()
{
$valid = true;
$booking = new BookingForm();
if (isset($_POST['BookingForm'])) {
$booking->attributes = $_POST['BookingForm'];
$valid = $booking->validate() && $valid;
} else {
$valid = false;
}
$passport = new AviaPassportForm();
if (isset($_POST['PassportForm'])) {
$passport->attributes = $_POST['PassportForm'];
$valid = $valid && $passport->validate();
}
if ($valid) {
//saving data to objects
$bookingAr = new Booking();
$bookingAr->email = $booking->contactEmail;
$bookingAr->phone = $booking->contactPhone;
if (!Yii::app()->user->isGuest) {
$bookingAr->userId = Yii::app()->user->id;
}
$bookingPassports = array();
$bookingPassport = new BookingPassport();
$bookingPassport->birthday = $passport->birthday;
$bookingPassport->firstName = $passport->firstName;
$bookingPassport->lastName = $passport->lastName;
$bookingPassport->countryId = $passport->countryId;
$bookingPassport->number = $passport->number;
$bookingPassport->series = $passport->series;
$bookingPassport->genderId = $passport->genderId;
$bookingPassport->documentTypeId = $passport->documentTypeId;
$bookingPassports[] = $bookingPassport;
$bookingAr->bookingPassports = $bookingPassports;
$bookingAr->flightId = Yii::app()->flightBooker->current->flightVoyage->flightKey;
if ($bookingAr->save()) {
Yii::app()->flightBooker->current->bookingId = $bookingAr->id;
Yii::app()->flightBooker->status('booking');
$this->refresh();
} else {
$this->render('enterCredentials', array('passport' => $passport, 'booking' => $booking));
}
} else {
$this->render('enterCredentials', array('passport' => $passport, 'booking' => $booking));
}
}
示例7: create
/**
* POST /bookings/create
*/
public function create()
{
self::authorize_user();
if (isset($_POST['patient_id']) && isset($_POST['doctor_id']) && isset($_POST['time__date']) && isset($_POST['time__hour'])) {
date_default_timezone_set('America/Buenos_Aires');
$patient_id = $_POST['patient_id'];
$doctor_id = $_POST['doctor_id'];
$time = $_POST['time__date'] . " " . $_POST['time__hour'];
// Cambiamos al formato que maneja la base de datos
$time = date_create_from_format('d-m-Y H:i', $time)->format('Y-m-d H:i');
$booking = new Booking($patient_id, $doctor_id, $time);
$booking->save();
self::redirect_to('bookings');
} else {
self::redirect_to('bookings/new');
}
}
示例8: showCreateBookingPage
private function showCreateBookingPage()
{
if (WebRequest::wasPosted()) {
try {
// get variables
$bcust = WebRequest::postInt("bcust");
$badults = WebRequest::postInt("badults");
$bchildren = WebRequest::postInt("bchildren");
$bstart = WebRequest::post("bstart");
$bend = WebRequest::post("bend");
$bpromo = WebRequest::postInt("bpromo");
$broom = WebRequest::postInt("broom");
// data validation
if ($badults == 0) {
throw new CreateBookingException("no-adults");
}
if ($bstart == null) {
throw new CreateBookingException("no-start-date");
}
if ($bend == null) {
throw new CreateBookingException("no-end-date");
}
if ($bcust == 0) {
throw new CreateBookingException("no-customer-for-booking");
}
$booking = new Booking();
// set values
$booking->setCustomer($bcust);
$booking->setAdults($badults);
$booking->setChildren($bchildren);
$booking->setStartDate($bstart);
$booking->setEndDate($bend);
$booking->setPromocode($bpromo);
$booking->setRoom($broom);
$booking->save();
global $cScriptPath;
$this->mHeaders[] = "Location: {$cScriptPath}/Bookings";
} catch (CreateBookingException $ex) {
$this->mBasePage = "mgmt/bookingCreate.tpl";
$this->error($ex->getMessage());
}
} else {
$this->mBasePage = "mgmt/bookingCreate.tpl";
}
}
示例9: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate($id)
{
if (!empty($id) && !Yii::app()->user->isGuest) {
$user_email = Yii::app()->user->name;
$userModel = User::model()->findByAttributes(array('user_email' => $user_email));
$listingId = $id;
$listingModel = Listing::model()->findByPk($listingId);
$model = new Booking();
$model->booking_listing_id = $listingModel->listing_id;
$model->booking_user_id = $userModel->user_id;
$model->booking_amount = $listingModel->listing_price;
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->booking_id));
}
} else {
echo "Booking failed";
}
}
示例10: book
public function book($userId, $post)
{
$offer = $this->getOffer($userId, $post['origin'], $post['destination'], $post['date'], $post['time']);
$response = new \StdClass();
$response->success = "no";
if ($offer->success == "yes") {
foreach (array('name', 'phone', 'email', 'passengerCount') as $fieldName) {
${$fieldName} = !empty($post[$fieldName]) ? $post[$fieldName] : '';
if (!${$fieldName}) {
$response->errorText = "Fyll in alla felt";
print json_encode($response);
exit;
}
}
$originCity = !empty($post['originCity']) ? $post['originCity'] : '';
$destinationCity = !empty($post['destinationCity']) ? $post['destinationCity'] : '';
// save to db
$booking = new Booking();
$booking->user_id = $userId;
$booking->alphaId = "ZZZ" . substr("" + time(), 3, 7);
$booking->origin = $offer->offerFrom;
$booking->destination = $offer->offerTo;
$booking->originCity = $originCity;
$booking->destinationCity = $destinationCity;
$booking->startUts = $offer->uts;
$booking->endUts = $offer->uts + $offer->offerDurationValue;
$booking->duration = $offer->offerDuration;
$booking->distance = $offer->offerDistance;
$booking->price = $offer->offerPrice;
$booking->name = $name;
$booking->email = $email;
$booking->phone = $phone;
$booking->passengerCount = $passengerCount;
$booking->hash = md5($name . $email . $offer->offerFrom . time() . "38lx93øå");
$response->bookingSaved = $booking->save();
// mail to customer
TaxiMail::sendBookingReceivedMail($booking, $userId);
// mail to taxi company
TaxiMail::sendNewBookingMail($booking, $userId);
$response->success = "yes";
}
return $response;
}
示例11: store
/**
* Store a newly created booking in storage.
*
* @return Response
*/
public function store()
{
$validator = Validator::make($data = Input::all(), Booking::$rules);
if ($validator->fails()) {
return Redirect::back()->withErrors($validator)->withInput();
}
$client = Client::findOrFail(Input::get('client_id'));
$car = Car::findOrFail(Input::get('car_id'));
$booking = new Booking();
$booking->client()->associate($client);
$booking->car()->associate($car);
$booking->date = date('Y-m-d');
$booking->destination = Input::get('destination');
$booking->date_out = Input::get('date_out');
$booking->date_back = Input::get('date_back');
$booking->status = 'active';
$booking->save();
return Redirect::route('bookings.index');
}
示例12: insertBooking
public function insertBooking()
{
if (!Request::ajax()) {
return "not a json request";
}
$post = Input::except('Notifees');
$notifees = Input::get('Notifees');
$booking = new Booking();
$booking->fill($post);
$booking->save();
$bookingDetail = new BookingDetails();
$bookingDetail->fill(array('BookingID' => $booking->ID, 'UserID' => Auth::user()->id, 'Email' => Auth::user()->email, 'Booker' => 1))->save();
if (count($notifees) > 0) {
foreach ($notifees as $notifee) {
$temp = User::where('email', $notifee['Email'])->first();
if ($temp != null) {
$bookingDetail = new BookingDetails();
$bookingDetail->fill(array('BookingID' => $booking->ID, 'UserID' => $temp->id, 'Email' => $temp->email, 'Booker' => 0));
$bookingDetail->save();
} else {
$bookingDetail = new BookingDetails();
$bookingDetail->fill(array('BookingID' => $booking->ID, 'Email' => $notifee['Email'], 'Booker' => 0));
$bookingDetail->save();
}
}
}
/*
Logs::BookingRequestCreated(
$booking->ID,
$post['KitID'],
$post['ForBranch'],
$post['StartDate'],
$post['EndDate']
);
*/
return Response::json(array('success' => true, 'insert_id' => $booking->ID), 200);
}
示例13: runPage
protected function runPage()
{
if (WebRequest::wasPosted()) {
if (!WebRequest::postInt("calroom")) {
$this->showCal();
return;
}
$startdate = new DateTime(WebRequest::post("qbCheckin"));
$enddate = new DateTime(WebRequest::post("qbCheckout"));
$room = Room::getById(WebRequest::postInt("calroom"));
for ($date = $startdate; $date < $enddate; $date->modify("+1 day")) {
if (!$room->isAvailable($date)) {
$this->error("room-not-available");
$this->showCal();
return;
}
}
// search for customer
if (!($customer = Customer::getByEmail(WebRequest::post("qbEmail")))) {
$customer = new Customer();
$suTitle = WebRequest::post("qbTitle");
$suFirstname = WebRequest::post("qbFirstname");
$suLastname = WebRequest::post("qbLastname");
$suAddress = WebRequest::post("qbAddress");
$suCity = WebRequest::post("qbCity");
$suPostcode = WebRequest::post("qbPostcode");
$suCountry = WebRequest::post("qbCountry");
$suEmail = WebRequest::post("qbEmail");
$customer->setPassword($suEmail);
// set values
$customer->setTitle($suTitle);
$customer->setFirstname($suFirstname);
$customer->setSurname($suLastname);
$address = new Address();
$address->setLine1($suAddress);
$address->setCity($suCity);
$address->setPostCode($suPostcode);
$address->setCountry($suCountry);
$address->save();
$customer->setAddress($address);
$customer->setEmail($suEmail);
// save it
$customer->save();
$customer->sendMailConfirm();
// save it again
$customer->save();
}
$booking = new Booking();
$booking->setStartDate(WebRequest::post("qbCheckin"));
$booking->setEndDate(WebRequest::post("qbCheckout"));
$booking->setAdults(WebRequest::post("qbAdults"));
$booking->setChildren(WebRequest::post("qbChildren"));
$booking->setPromocode(WebRequest::post("qbPromoCode"));
$booking->setRoom($room->getId());
$booking->setCustomer($customer->getId());
$booking->save();
$msg = Message::getMessage("booking-confirmation");
$msg = str_replace("\$1", $booking->getStartDate(), $msg);
$msg = str_replace("\$2", $booking->getEndDate(), $msg);
$msg = str_replace("\$3", $booking->getAdults(), $msg);
$msg = str_replace("\$4", $booking->getChildren(), $msg);
$msg = str_replace("\$5", $booking->getRoom()->getName(), $msg);
Mail::send($customer->getEmail(), Message::getMessage("booking-confimation-subject"), $msg);
$this->mSmarty->assign("content", $msg);
return;
}
throw new YouShouldntBeDoingThatException();
}
示例14: bookingStep2
public function bookingStep2($id)
{
$i = Input::all();
$i['checkin'] = $i['checkin'] . ' 12:00:00';
//
$i['checkout'] = $i['checkout'] . ' 11:59:00';
$total_price = null;
$tax = null;
$booking_session = [];
$count = 0;
//for test
$count1 = 0;
//for test
$booked_room = [];
//all picked rooms from available rooms
$booked_room_id = [];
//foreach(Session::get('reservation')['reservation_room'] as $rooms){
$count++;
$room_id = $id;
$available_rooms = [];
$room_qty = RoomQty::with(array('roomPrice', 'roomReserved' => function ($query) use($i, $room_id) {
$query->where(function ($query2) use($i, $room_id) {
$query2->whereBetween('check_in', array($i['checkin'], $i['checkout']))->orWhereBetween('check_out', array($i['checkin'], $i['checkout']))->orWhereRaw('"' . $i["checkin"] . '" between check_in and check_out')->orWhereRaw('"' . $i["checkout"] . '" between check_in and check_out');
})->where(function ($query3) {
$query3->where('status', '!=', 5)->where('status', '!=', 3);
});
}))->where('status', 1)->where('room_id', $room_id)->get();
foreach ($room_qty as $available) {
if (count($available->roomReserved) == 0) {
array_push($available_rooms, $available);
} else {
}
}
if (!empty($available_rooms)) {
for ($counter = 0; $counter < $i['quantity']; $counter++) {
array_push($booked_room, $available_rooms[$counter]);
}
} else {
return '0';
//not available
}
//} //end of foreach
$total_price = 0;
if (!isset($_GET['bookingId'])) {
$new_booking = new Booking();
$new_booking->firstname = 'WALK-IN';
$new_booking->lastname = 'WALK-IN';
$new_booking->address = 'WALK-IN';
$new_booking->contact_number = '000';
$new_booking->check_in = $i['checkin'];
$new_booking->check_out = $i['checkout'];
$new_booking->email_address = 'WALK-IN';
$new_booking->code = 'N/A';
$new_booking->status = 0;
$new_booking->save();
}
foreach ($booked_room as $b) {
$ci = new Carbon($i['checkin']);
$co = new Carbon($i['checkout']);
$total_nights = $co->diff($ci)->days;
$total_nights += 1;
$total_price += $total_nights * $b->roomPrice->price;
$total_price2 = $total_nights * $b->roomPrice->price;
//$tax = $total_price2 * 0.12;
//$total_price2+=$tax;
$reserveRoom = new ReservedRoom();
$reserveRoom->room_id = $b->id;
$reserveRoom->room_type = $b->room_id;
$reserveRoom->booking_id = isset($_GET['bookingId']) ? $_GET['bookingId'] : $new_booking->id;
$reserveRoom->check_in = $i['checkin'];
$reserveRoom->check_out = $i['checkout'];
$reserveRoom->code = 'N/A';
/*$reserveRoom->firstname = 'WALK-IN';
$reserveRoom->lastname = 'WALK-IN';*/
$reserveRoom->price = $total_price2;
/*$reserveRoom->address = 'WALK-IN';
$reserveRoom->contact_number = '000';
$reserveRoom->email_address = 'WALK-IN';*/
$reserveRoom->status = '0';
if ($reserveRoom->save()) {
array_push($booked_room_id, $reserveRoom->id);
}
}
if (isset($_GET['bookingId'])) {
$existing_booking = Booking::where('id', $_GET['bookingId'])->first();
if ($existing_booking) {
$existing_booking->price = $total_price;
}
} else {
$new_booking->price = $total_price;
$new_booking->save();
}
// return Session::get('reservation');
//return $booked_room;
//return $counter;
//return $room_qty1;
$booking_session['booking_id'] = isset($_GET['bookingId']) ? $_GET['bookingId'] : $new_booking->id;
$booking_session['rooms'] = $booked_room_id;
return $booking_session;
}
示例15: clientBookingStep5
public function clientBookingStep5()
{
//return Session::get('reservation');
$tax = null;
$total_price = null;
$i = [];
$i['checkin'] = Session::get('reservation')['checkin'] . ' 12:00:00';
$i['checkout'] = Session::get('reservation')['checkout'] . '11:59:00';
$customerinformation = Session::get('reservation.customerinformation');
$count = 0;
//for test
$count1 = 0;
//for test
$booked_room = [];
//all picked rooms from available rooms
$new_booking = new Booking();
$new_booking->firstname = $customerinformation['firstname'];
$new_booking->lastname = $customerinformation['lastname'];
$new_booking->address = $customerinformation['address'];
$new_booking->contact_number = $customerinformation['contact_no'];
$new_booking->email_address = $customerinformation['email'];
$new_booking->check_in = $i['checkin'];
$new_booking->check_out = $i['checkout'];
$new_booking->save();
foreach (Session::get('reservation')['reservation_room'] as $rooms) {
$count++;
$room_id = $rooms['room_details']['id'];
$available_rooms = [];
$room_qty = RoomQty::with(array('roomPrice', 'roomReserved' => function ($query) use($i, $room_id) {
$query->where(function ($query2) use($i, $room_id) {
$query2->whereBetween('check_in', array($i['checkin'], $i['checkout']))->orWhereBetween('check_out', array($i['checkin'], $i['checkout']))->orWhereRaw('"' . $i["checkin"] . '" between check_in and check_out')->orWhereRaw('"' . $i["checkout"] . '" between check_in and check_out');
})->where(function ($query3) {
$query3->where('status', '!=', 5)->where('status', '!=', 3);
});
}))->where('room_id', $room_id)->get();
foreach ($room_qty as $available) {
if ($available->roomReserved == '[]') {
array_push($available_rooms, $available);
}
}
for ($counter = 0; $counter < $rooms['quantity']; $counter++) {
array_push($booked_room, $available_rooms[$counter]);
}
}
//end of foreach
$total = 0;
if (!empty($booked_room)) {
foreach ($booked_room as $b) {
$total += $b->roomPrice->price * Session::get('reservation.nights');
$tax = $total * 0.12;
$total = $total + $tax;
$reserveRoom = new ReservedRoom();
$reserveRoom->booking_id = $new_booking->id;
$reserveRoom->room_id = $b->id;
$reserveRoom->price = $total;
/*$reserveRoom->check_in = $i['checkin'];
$reserveRoom->check_out = $i['checkout'];
$reserveRoom->firstname = $customerinformation['firstname'];
$reserveRoom->lastname = $customerinformation['lastname'];
$reserveRoom->address = $customerinformation['address'];
$reserveRoom->contact_number = $customerinformation['contact_no'];
$reserveRoom->email_address = $customerinformation['email'];*/
$reserveRoom->save();
}
}
$tax = $total * 0.12;
$total = $total + $tax;
$new_booking->price = $total;
$new_booking->save();
return Redirect::to('booking/step5');
}