/** * @param null $startDate * @param null $endDate */ public function getHoursByDate($startDate = null, $endDate = null, $returnOnlyHours = false) { if ($startDate == null) { $startDate = Carbon::now()->firstOfMonth()->format('Y-m-d'); } if ($endDate == null) { $endDate = Carbon::now()->endOfMonth()->format('Y-m-d'); } $hours = $this->repository->getHoursByDate($startDate, $endDate); $groupedHours = $this->groupHoursByDate($hours); $result = $this->calculateBalance($groupedHours); if ($returnOnlyHours) { return $result['totalWorkedHours']; } return $result; }
public function removeAction(Request $request, $id) { $hourControl = $this->repository->findById($id); if (!$hourControl) { $request->session()->flash('message', "Register [{$id}] not found"); return redirect('hours-control'); } HoursControl::destroy($id); $request->session()->flash('message', "Successfully removed register [{$id}]"); $request->session()->flash('success', true); return redirect('hours-control'); }