コード例 #1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, Requests\CreateShift $request)
 {
     $input = Request::all();
     $payableHours = strtotime($input['endShift']) - strtotime($input['startShift']);
     $overtimeHours = 0;
     //check for unpaid breaks
     if ($payableHours >= 18000) {
         $payableHours = $payableHours - 1800;
     }
     //check for overtime hours and format accordingly
     if ($payableHours > 28800) {
         $overtimeHours = $payableHours - 28800;
         $overtimeHours = $overtimeHours / 3600;
         $payableHours = 28800;
     }
     $payableHours = $payableHours / 3600;
     $calendar = Calendar::findOrFail($id);
     $calendar->startShift = new Carbon($input['date'] . " " . $input['startShift']);
     $calendar->endShift = new Carbon($input['date'] . " " . $input['endShift']);
     $calendar->payableHours = $payableHours;
     $calendar->overtimeHours = $overtimeHours;
     $calendar->shiftDate = $input['date'];
     $calendar->save();
     return redirect('home');
 }