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 static function current_nights() { return WellbeingNight::where('year_id', '=', Year::current_year()->id); }
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_night_add($bundle_id, $night_id) { $bundle = WellbeingBundle::find($bundle_id); $night = WellbeingNight::find($night_id); $bundle->nights()->attach($night); return Redirect::to('rms/wellbeing/bundles/manage/' . $bundle_id); }
public function get_delete($id) { $night = WellbeingNight::find($id)->delete(); return Redirect::to('rms/wellbeing/nights')->with('success', 'Successfully Removed Night'); }