public function now() { $history = LeaveRequest::with('user')->with('entitlement')->where('mgr_id', '=', 6)->orderBy('id', 'DESC')->take(20)->get(); return $history; //$leaves = User::with('leaveRequest')->where('id', '=', 6)->get(); //return $leaves; // return Config::get('systech.annual_start_date'); // $enrolls = Enroll::with('sassions')->orderBy('id', 'DESC')->take(10)->get(); /*$leaveSum = DB::table('leave_requests')->where('user_id', '=', 6) ->where('entitlement_id', '=', 1)->sum('no_of_days'); echo $leaveSum; */ }
public function showApproveRequest() { $userId = $this->getUserId(); $histories = LeaveRequest::with('user')->with('entitlement')->where('mgr_id', '=', $userId)->orderBy('id', 'DESC')->take(20)->get(); $leave_history = array(); foreach ($histories as $history) { $row = array(); $row['id'] = $history['id']; $row['user_id'] = $history['id']; $row['no_of_days'] = $history['no_of_days']; $row['from_date'] = $history['from_date']; $row['to_date'] = $history['to_date']; $row['status'] = $history['status']; $user = $history['user']; $row['user_name'] = $user['first_name'] . ' ' . $user['last_name']; $ent = $history['entitlement']; $row['entitlement_name'] = $ent['name'] . ' (' . $ent['no_of_days'] . ' days)'; $leave_history[] = $row; } return Response::jsend('success', $leave_history); }