/** * @param array $step */ public function internalStore(array $step) { $this->step = new Step(); if ($this->step->where('step_id', $step['date']->minute(0)->second(0)->format('YmdH'))->exists()) { } else { $this->setStep($step); $this->step->save(); } }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function getStepCharts() { $stepToday = $this->getStepsTodayChart(); $dataTableRows = Step::select(DB::raw('date, steps'))->groupby('date')->orderby('date', 'desc')->skip(1)->take(90)->get(); $stepChart = $this->getStepChart($dataTableRows); $dataTableRows = Step::select(DB::raw('date, duration/60 as duration'))->groupby('date')->orderby('date', 'desc')->take(90)->get(); $durationChart = $this->getDurationChart($dataTableRows); $dataTableRows = Step::select(DB::raw('date, steps/duration as pace'))->groupby('date')->orderby('date', 'desc')->take(90)->get(); $paceChart = $this->getPaceChart($dataTableRows); return view('pages.ActivitySteps', ['durationchart' => $durationChart, 'stepchart' => $stepChart, 'pacecount' => $paceChart, 'stepToday' => $stepToday]); }
private function storeStep($stepArray) { $step = Step::firstOrNew(['date' => $stepArray['date']]); $step->steps = $stepArray['steps']; $step->duration = $stepArray['duration']; return $step->save(); }