public function total() { $mynight_count = count($this->nights); $allnight_count = count(WellbeingNight::current_nights()->get()); $total = 0; foreach ($this->nights as $night) { if ($mynight_count == $allnight_count) { $total += $night->special_price; } else { $total += $night->price; } } return $total; }
public function get_manage($id) { $bundle = WellbeingBundle::find($id); $all_nights = WellbeingNight::current_nights()->get(); $nights = array(); # TODO do this with sql foreach ($all_nights as $night) { $contains = false; foreach ($bundle->nights()->get() as $n) { if ($night->id == $n->id) { $contains = true; break; } } if (!$contains) { $nights[] = $night; } } return View::make('wellbeing.bundles.manage')->with('bundle', $bundle)->with('nights', $nights); }
public function post_paid($id) { $input = Input::get(); $rules = array('paid' => 'required|numeric'); $validation = Validator::make($input, $rules); if ($validation->passes()) { $yes = Input::get('yes'); unset($input['yes']); $wellbeing_order = WellbeingOrder::find($id); $wellbeing_order->update($input); $wellbeing_order->nights()->detach(); if ($yes) { foreach (WellbeingNight::current_nights()->get() as $night) { if (array_key_exists($night->id, $yes)) { $wellbeing_order->nights()->attach($night->id); } } } return Redirect::to('rms/wellbeing/orders/admin')->with('success', 'Successfully Edited Order'); } else { return Redirect::to('rms/wellbeing/orders/paid/{{$id}}')->withErrors($validation)->withInput(); } }
public function get_index() { $nights = WellbeingNight::current_nights()->orderBy('date')->get(); return View::make('wellbeing.nights.index')->with('nights', $nights); }