public function batchesByClassSeasonId() { $inputs = Input::all(); $classId = Input::get('classId'); $seasonId = Input::get('seasonId'); $batches = Batches::batchesByClassIdSeasonId($classId, $seasonId); $batchesJson = array(); $i = 0; foreach ($batches as $batch) { $batchesJson[$i]['id'] = $batch->id; $batchesJson[$i]['batch_name'] = $batch->batch_name; $batchesJson[$i]['day'] = date('l', strtotime($batch->start_date)); $batchesJson[$i]['start_time'] = date('G:i a', strtotime($batch->preferred_time)); $batchesJson[$i]['end_time'] = date('G:i a', strtotime($batch->preferred_end_time)); if (isset($batch->LeadInstructors->first_name)) { $batchesJson[$i]['instructor'] = '(' . $batch->LeadInstructors->first_name . ' ' . $batch->LeadInstructors->last_name . ')'; } else { $batchesJson[$i]['instructor'] = ''; } $i++; } header('Access-Control-Allow-Origin: *'); return Response::json($batchesJson); }