/** * Changes business day by variable 'new_date' * * * @return \Illuminate\Http\Response */ public function changeDay() { SwapsController::final_store(); $trader = User::findOrFail(\Auth::user()->id); $swaps = Swap::where('company', $trader->company)->get(); $current_date = null; foreach ($swaps as $swap) { $date = Carbon::parse(Input::get('new_date')); $swap->business_date = $date; $swap->update(); $current_date = $date; if (Carbon::parse($swap->end_date)->diffInWeekdays(Carbon::parse($current_date)) <= 5 && Carbon::parse($swap->end_date) >= Carbon::parse($current_date)) { $swap['maturity'] = 1; } else { } $swap['current_spread'] = $swap->fixed_rate - $swap->floating_spread + rand(-100, 100) / 100; } return View::make('swapMaturities')->with('trader', $trader)->with('swaps', $swaps)->with('current_date', $current_date); }