Esempio n. 1
0
 /**
  * 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 showModuleFeedback()
 {
     $modules = WingmanModule::all();
     //return $modules;
     $entries = DB::table('propel_wingmanJournals as A')->join('User as B', 'B.id', '=', 'A.wingman_id')->join('Student as C', 'C.id', '=', 'A.student_id')->join('Center as D', 'D.id', '=', 'C.center_id')->join('City as E', 'E.id', '=', 'D.city_id')->select('A.id as id', 'A.title as title', 'B.name as wingman_name', 'E.name as city_name', 'A.on_date as on_date', 'A.module_id as module_id')->distinct()->where('A.type', '=', 'module_feedback')->get();
     return View::make('feedback/module_feedback')->with('entries', $entries)->with('modules', $modules);
 }
Esempio n. 3
0
 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);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $je = WingmanJournal::find($id);
     $wingman_id = $je->wingman_id;
     $je->type = Input::get('type');
     $type = Input::get('type');
     if ($type == "module_feedback") {
         $moduleName = WingmanModule::where('id', '=', Input::get('title'))->get();
         $je->title = $moduleName[0]->name;
     } else {
         $je->title = Input::get('title');
     }
     $je->on_date = date_format(date_create(Input::get('pickdate')), 'Y-m-d');
     $je->mom = Input::get('mom');
     $je->student_id = Input::get('student');
     $je->save();
     return Redirect::to(URL::to('/') . "/wingman-journal/" . $wingman_id);
 }