public function showAttendanceToFellow($wingman_id) { $wingmans_kids = Wingman::find($wingman_id)->student()->get(); if (empty($wingmans_kids[0])) { return Redirect::to('error')->with('message', 'There are no students assigned to the wingman'); } $student_ids = array(); foreach ($wingmans_kids as $wk) { $student_ids[] = $wk->id; } $attended = CalendarEvent::whereIn('student_id', $student_ids)->where('type', '<>', 'child_busy')->where(function ($query) { $query->where('status', 'approved')->orWhere('status', 'attended'); })->where('start_time', '>=', $this->year_time)->get(); //return $attended; /*foreach ($attended as $entry) { if($entry->type = 'volunteer_time') { $variable = $entry->volunteerTime()->first(); if(!empty($variable)) echo $entry->volunteerTime()->first()->volunteer()->first()->name; } else if($entry->type = 'wingman_time') { //echo $entry->wingmanTime()->first()->wingman()->first()->name; } }*/ //return 'Hi'; return View::make('attendance.attended-list')->with('attended', $attended); }