Example #1
0
 /**
  * Prepare an experiment for this session.
  *
  * @return string
  */
 protected function nextExperiment($experiment = null)
 {
     // Verify that the experiments are in the database.
     $this->checkExperiments();
     if ($experiment) {
         $experiment = Experiment::active()->findOrfail($experiment);
     } else {
         $experiment = Experiment::active()->orderBy('visitors', 'asc')->firstOrFail();
     }
     $this->session->set('experiment', $experiment->name);
     // Since there is an ongoing experiment, increase the pageviews.
     // This will only be incremented once during the whole experiment.
     $this->pageview();
     return $experiment->name;
 }