/**
  * @param  int $userId
  * @return \Otman\Http\Request
  */
 public function create($userId, Request $request)
 {
     $this->validate($request, array('request_date' => 'required', 'description' => 'required'));
     $user = User::find($userId);
     $overtime = new Overtime();
     $overtime->user_id = $userId;
     $overtime->request_date = $request->request_date;
     $overtime->description = $request->description;
     $overtime->status = Overtime::STATUS_PENDING;
     if ($overtime->save()) {
         Event::fire(new OvertimeRequested($user, $overtime));
         return redirect('dashboard')->with('success', 'Your overtime request was successfully submitted.');
     }
     return view('entity.overtime.new')->with('fail', 'Your overtime request could not be submitted. Please try again.');
 }
 /**
  * @param  int $id
  * @param  \Illuminate\Http\Request $request
  * @return array
  */
 public function logTime($id, Request $request)
 {
     $validator = Validator::make($request->all(), array('time' => 'required|date_format:g:i'));
     if ($validator->fails()) {
         return array('code' => 3, 'status' => 'Validation failed', 'message' => $validator->errors());
     }
     $overtime = Overtime::find($id);
     $overtime->logged_time = $request->time;
     $overtime->status = Overtime::STATUS_COMPLETED;
     if ($overtime->save()) {
         return array('code' => 1, 'status' => 'ok', 'message' => 'Your overtime has been logged.');
     } else {
         return array('code' => 2, 'status' => 'error', 'message' => 'Cannot log your overtime. Try again.');
     }
 }