本文整理汇总了PHP中Reservation::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Reservation::find方法的具体用法?PHP Reservation::find怎么用?PHP Reservation::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reservation
的用法示例。
在下文中一共展示了Reservation::find方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getReservation
public function getReservation($id)
{
$reservation = Reservation::find($id);
if (!$reservation) {
return Redirect::to('admin/reservation');
}
$this->layout->body = View::make('admin.reservation')->with('reservation', $reservation);
}
示例2: cancel_reservation
public static function cancel_reservation($id)
{
$user = self::get_user_logged_in();
$reservation = Reservation::find($id);
$date_limit = new DateTime();
$date_limit->add(new DateInterval('P1D'));
if ($reservation) {
if ($reservation->user->id != $user->id && !$user->manager) {
Redirect::to(\Slim\Slim::getInstance()->urlFor('reservations_index'), array('message' => 'Varausta ei löydy!', 'error' => true));
} else {
if ($reservation->reserved_to <= $date_limit) {
Redirect::to(\Slim\Slim::getInstance()->urlFor('reservations_index'), array('message' => 'Varauksen voi peruuttaa viimeistään vuorokautta ennen varauksen ajankohtaa', 'error' => true));
} else {
$reservation->delete();
Redirect::to(\Slim\Slim::getInstance()->urlFor('reservations_index'), array('message' => 'Varaus peruutettu!'));
}
}
} else {
Redirect::to(\Slim\Slim::getInstance()->urlFor('reservations_index'), array('message' => 'Varausta ei löydy!', 'error' => true));
}
}
示例3: getReserveClose
public function getReserveClose($id = null)
{
if (!isset($id) or is_null($id)) {
return Redirect::to('/admin/reserve');
}
$query = Reservation::find($id);
if (is_null($query)) {
return Redirect::to('/admin/reserve');
}
$query->status = 2;
$query->save();
return Redirect::to('admin/reserve/' . $id)->with('message', "The reservation has been closed!");
}
示例4: delete
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function delete($id)
{
$this->reservation->find($id)->delete();
return Redirect::route('admin.reservations.index');
}
示例5: destroy
/**
* Remove the specified resource from storage.
* DELETE /reservations/{id}
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
Reservation::find($id)->delete();
return Response::json(['data' => 'Reservation deleted'], 200);
}
示例6: updateMenuReservation
public function updateMenuReservation()
{
$reservation = Reservation::find(Input::get('id'));
if (!$reservation) {
return Redirect::back()->withErrors('Could not find reservation.');
}
//$reservation->menus()->detach();
//$reservation->items()->detach();
$date1 = new DateTime($reservation->reservation_start);
$date2 = new DateTime($reservation->reservation_end);
$diff = $date2->diff($date1)->format("%a");
$diff += 1;
$date1 = date_format($date1, 'l, jS F Y');
$date2 = date_format($date2, 'l, jS F Y');
$id = Input::get('id');
$total_price = 0;
$package_price = 0;
$pricezs = 0;
$qty = Input::get('quantity');
$model = Input::get('model');
$invid = Input::get('invId');
$pricey = Input::get('pricey');
foreach ($reservation->menu() as $value) {
$total_price += $value->price;
}
foreach ($reservation->item as $value) {
}
for ($i = 0; $i < count($qty); $i++) {
if ($qty[$i] > 0) {
$reservation->items()->attach($invid[$i], ['qty' => $qty[$i]]);
$pricezs = $pricezs + (int) $pricey[$i] * $qty[$i];
}
}
for ($index = 1; $index <= $diff; $index++) {
if (count(Input::get('menu' . $index)) > 0) {
foreach (Input::get('menu' . $index) as $menu) {
$reservation->menus()->attach($menu, ['day' => $index]);
$price = Menu::find($menu);
$total_price += $price->price;
}
}
if (count(Input::get('package' . $index)) > 0) {
foreach (Input::get('package' . $index) as $package) {
foreach (DB::table('menu_package')->where('package_id', '=', $package)->get() as $fuckage) {
$reservation->menus()->attach($fuckage->menu_id, ['day' => $index, 'package' => $package]);
}
$price = Packages::find($package);
$package_price += $price->price;
}
}
}
$reservation->net_total = $total_price * $reservation->pax + $package_price + $pricezs;
if ($reservation->save()) {
return Redirect::back()->with('flash_message', 'Reservation has been saved!');
} else {
return Redirect::back()->withErrors('Could not update reservation');
}
}
示例7: deleteReservation
/**
* Cancel the reservation with id $id by deleting it from database.
* @param $clustername : the cluster's name
* @param $id : the reservation's id
*/
public function deleteReservation(Cluster $cluster, $id)
{
//TODO cluster not used with a valid cluster anyone can delete any reservation
$reservation = Reservation::find($id);
if (isset($reservation)) {
$reservation->delete();
} else {
return $this->_sendErrorMessage(404, "Reservation.NotFound", "Reservation not found.");
}
}
示例8: Reservation
$rsv_id = 0;
$rsv = new Reservation();
try {
$rsv_id = $rsv->create($fields);
$success = true;
$message = 'New reservation creation is complete.<br>';
echo $message;
} catch (Exception $e) {
$success = false;
$message = $e->getMessage();
echo "Creating a new reservation Error: " . $message . "<br>";
}
echo ($success == true ? "SUCCESS" : "FAILURE") . "<br>";
try {
echo "<br>Testing find reservation:<br>";
$success = $rsv->find($rsv_id);
print_r($rsv->get_reservation_info());
echo "<br>";
echo $rsv->get_reservation_info_json();
echo "<br>";
} catch (Exception $e) {
$success = false;
$message = $e->getMessage();
echo "Find reservation Error: " . $message . "<br>";
}
echo ($success == true ? "SUCCESS" : "FAILURE") . "<br>";
try {
echo "<br>Testing find reservation by restaurant_id and user_id:<br>";
$success = $rsv->find_by_restaurant_and_user(3, 1, '01-02-2015');
print_r($rsv->get_reservation_info());
echo "<br>";