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); }
/** * Run the database seeds. * * @return void */ public function run() { Eloquent::unguard(); DB::table('propel_fellow_wingman')->delete(); DB::table('propel_student_wingman')->delete(); Subject::truncate(); DB::table('propel_city_subject')->delete(); CalendarEvent::truncate(); CancelledCalendarEvent::truncate(); WingmanModule::truncate(); WingmanTime::truncate(); VolunteerTime::truncate(); WingmanJournal::truncate(); $fellow = Fellow::find(1); $wingman1 = Wingman::find(2); $wingman2 = Wingman::find(3); $fellow->wingman()->attach($wingman1); $fellow->wingman()->attach($wingman2); $student1 = Student::find(3); $student2 = Student::find(4); $wingman1->student()->attach($student1); $wingman1->student()->attach($student2); $cEvent1 = new CalendarEvent(); $cEvent1->type = 'volunteer_time'; $cEvent1->student()->associate($student1); $cEvent1->status = 'created'; $cEvent1->save(); $vTime1 = new VolunteerTime(); $vTime1->calendarEvent()->associate($cEvent1); $volunteer1 = Volunteer::find(4); $vTime1->volunteer()->associate($volunteer1); $subject1 = new Subject(); $subject1->name = "English"; $subject1->save(); $vTime1->subject()->associate($subject1); $vTime1->save(); $cEvent2 = new CalendarEvent(); $cEvent2->type = 'wingman_time'; $cEvent2->student()->associate($student1); $cEvent2->status = 'created'; $cEvent2->save(); $wTime1 = new WingmanTime(); $wTime1->calendarEvent()->associate($cEvent2); $wTime1->wingman()->associate($wingman1); $wModule1 = new WingmanModule(); $wModule1->name = "Programming"; $wModule1->save(); $wTime1->wingmanModule()->associate($wModule1); $wTime1->save(); $city1 = City::find(1); $subject1->city()->attach($city1); $wJournal1 = new WingmanJournal(); $wJournal1->type = 'formal'; $wJournal1->title = "Day at Navy Camp"; $wJournal1->mom = "It was awesome"; $wJournal1->student()->associate($student1); $wJournal1->wingman()->associate($wingman1); $wJournal1->save(); }
public function showCalendar($wingman_id, $student_id) { $this->setGroup(); $city = Wingman::find($wingman_id)->city()->first(); $volunteers = Group::where('name', $this->asvGroupName)->first()->volunteer()->where('city_id', '=', $city->id)->where('status', '=', 1)->where('user_type', '=', 'volunteer')->groupby('id')->get(); //return $volunteers; $subjects = Wingman::find($wingman_id)->city()->first()->subject()->get(); $wingman_modules = WingmanModule::all(); /*$calendarEvents = DB::table('propel_calendarEvents as P')->select('P.id','P.type as title','P.start_time as start','P.end_time as end')->where('student_id','=',$student_id)->get(); */ $calendarEvents = DB::table('propel_calendarEvents as P')->leftJoin('propel_cancelledCalendarEvents as Q', 'P.id', '=', 'Q.calendar_event_id')->leftJoin('propel_wingmanTimes as R', 'R.calendar_event_id', '=', 'P.id')->leftJoin('propel_volunteerTimes as S', 'S.calendar_event_id', '=', 'P.id')->leftJoin('User as T', 'T.id', '=', 'S.volunteer_id')->leftJoin('User as U', 'U.id', '=', 'R.wingman_id')->leftJoin('propel_wingmanModules as V', 'V.id', '=', 'R.wingman_module_id')->leftJoin('propel_subjects as W', 'W.id', '=', 'S.subject_id')->select('P.id', 'P.type as title', 'P.start_time as start', 'P.end_time as end', 'P.status', 'Q.reason as reason', 'Q.comment as comment', 'U.name as wingman_name', 'T.name as volunteer_name', 'S.volunteer_id as volunteer_id', 'R.wingman_id as wingman_id', 'V.id as module_id', 'W.id as subject_id', 'V.name as module_name', 'W.name as subject_name')->where('student_id', '=', $student_id)->get(); foreach ($calendarEvents as $calendarEvent) { $calendarEvent->title = str_replace('_', ' ', $calendarEvent->title); $calendarEvent->title = ucwords($calendarEvent->title); $calendarEvent->reason = str_replace('_', ' ', $calendarEvent->reason); $calendarEvent->reason = ucwords($calendarEvent->reason); } $calendarEvents = json_encode($calendarEvents); $student_name = Student::where('id', '=', $student_id)->first(); $GLOBALS['student_id'] = $student_id; return View::make('calendar.calendar-view')->with('volunteers', $volunteers)->with('subjects', $subjects)->with('wingman_modules', $wingman_modules)->with('student_id', $student_id)->with('wingman_id', $wingman_id)->with('calendarEvents', $calendarEvents)->with('student_name', $student_name->name); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $journal_entry = WingmanJournal::find($id); $wingman_id = $journal_entry->wingman_id; $students = Wingman::find($wingman_id)->student()->get(); $moduleList = WingmanModule::all(); foreach ($moduleList as $module) { if ($module->id == $journal_entry->module_id) { } } return View::make('journal-entry.edit')->with('journal_entry', $journal_entry)->with('students', $students)->with('modules', $moduleList); }
public function showStudents($wingman_id) { $students = Wingman::find($wingman_id)->student()->get(); return View::make('feedback/show-students')->with('students', $students)->with('wingman_id', $wingman_id); }
public function saveStudents($wingman_id) { $user_id = $wingman_id; $wingmen = Wingman::find($user_id); $selected_students = Input::get("students"); if (!empty($selected_students)) { $wingmen->student()->sync($selected_students); } else { DB::table('propel_student_wingman')->where('wingman_id', '=', $wingman_id)->delete(); } return Redirect::to(URL::to('/') . "/settings/" . $wingman_id . "/students")->with('success', 'Students Set'); }