コード例 #1
0
 public function selectWingman()
 {
     $user_id = $_SESSION['user_id'];
     $fellow = Fellow::find($user_id);
     $wingmen = $fellow->wingman()->get();
     return View::make('attendance.select-wingman')->with('wingmen', $wingmen);
 }
コード例 #2
0
ファイル: DatabaseSeeder.php プロジェクト: makeadiff/propel
 /**
  * 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();
 }
コード例 #3
0
 public function selectStudentsCity()
 {
     $user_id = $_SESSION['user_id'];
     $fellow = Fellow::find($user_id);
     $city = $fellow->city()->first();
     //return $city->id;
     $students = DB::table('propel_student_wingman as A')->join('Student as B', 'A.student_id', '=', 'B.id')->join('Center as C', 'C.id', '=', 'B.center_id')->join('City as D', 'D.id', '=', 'C.city_id')->select('A.student_id', 'B.name', 'A.wingman_id')->distinct()->where('D.id', '=', $city->id)->get();
     //return $students;
     return View::make('feedback/select-students-city')->with('students', $students);
 }
コード例 #4
0
 public function saveWingmen()
 {
     $user_id = $_SESSION['user_id'];
     $fellow = Fellow::find($user_id);
     $selected_wingmen = Input::get("wingmen");
     if (!empty($selected_wingmen)) {
         $fellow->wingman()->sync($selected_wingmen);
     } else {
         DB::table('propel_fellow_wingman')->where('fellow_id', '=', $user_id)->delete();
     }
     return Redirect::to(URL::to('/') . "/settings/wingmen")->with('success', 'Wingmen Set.');
 }
コード例 #5
0
 public function approvalSummary()
 {
     $user_id = $_SESSION['user_id'];
     $fellow = Fellow::find($user_id);
     $wingmen = $fellow->wingman()->get();
     //$current_date = new DateTime()
     $current_month = date('c', strtotime("+1 month"));
     $i = 0;
     $datalist = DB::table('User as A')->join('propel_fellow_wingman as B', 'A.id', '=', 'B.fellow_id')->join('propel_student_wingman as C', 'C.wingman_id', '=', 'B.wingman_id')->join('User as D', 'D.id', '=', 'B.wingman_id')->join('Student as E', 'E.id', '=', 'C.student_id')->join('propel_calendarEvents as F', 'F.student_id', '=', 'C.student_id')->select('B.wingman_id as wingman_id', 'A.name as fellow_name', 'D.id as wingman_id', 'D.name as wingman_name', 'E.id as student_id', 'E.name as student_name', 'F.start_time as month')->where('A.id', '=', $user_id)->where('F.status', '!=', 'approved')->where('F.status', '!=', 'cancelled')->orderBy('student_id')->orderBy('month')->where('F.start_time', '<=', $current_month)->get();
     return $datalist;
 }