예제 #1
0
 public function count()
 {
     $total = 0;
     $orders = WellbeingOrder::current_orders()->get();
     foreach ($orders as $order) {
         if ($order->bundle() != null) {
             foreach ($order->bundle()->nights()->get() as $night) {
                 if ($night->id == $this->id) {
                     $total++;
                 }
             }
         }
     }
     return $this->orders()->count() + $total;
 }
예제 #2
0
 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();
     }
 }
예제 #3
0
 public static function current_orders()
 {
     return WellbeingOrder::where('year_id', '=', Year::current_year()->id);
 }