Ejemplo n.º 1
0
 public function onRun()
 {
     $this->sessions = Session::all()->toArray();
     $this->locationsBuilder;
     $locations = Session::orderBy('location')->get();
     $previousLocation = "";
     for ($i = 0; $i < count($locations); $i++) {
         //Check if the previous location is the same as this one, if not add it to the locationBuilder
         if (strcmp($previousLocation, $locations[$i]['location']) !== 0) {
             if ($i == 0) {
                 $this->locationsBuilder .= "'" . $locations[$i]['location'] . "'";
             } else {
                 $this->locationsBuilder .= ", '" . $locations[$i]['location'] . "'";
             }
         }
         $previousLocation = $locations[$i]['location'];
     }
     foreach ($this->sessions as &$session) {
         $session['end_time'] = gmdate("Y-m-d H:i:s", strtotime($session['start_time']) + $session['duration'] * 60);
     }
 }