Example #1
0
 public static function mass_drop($student_ids, $sid)
 {
     $messages = array();
     foreach ($student_ids as $student_id) {
         $user = User::findUserByStudentId($student_id);
         if ($user != null) {
             Enrollment::drop($user->id, $sid);
             $messages[] = $student_id . " dropped successfully";
         } else {
             $messages[] = $student_id . " does not exist";
         }
     }
     return $messages;
 }
 public function getData()
 {
     $user = Auth::user();
     //User::find(1);
     $enrollments = Enrollment::where('student_id', '=', $user->id)->get();
     $available_sections = $user->getAvailableSections();
     //Vsection::All();
     $enrolled_sections = array();
     foreach ($enrollments as $e) {
         $enrolled_sections[] = Vsection::find($e->section_id);
     }
     $data = array("status" => "success", "enrolled_sections" => $enrolled_sections, "available_sections" => $available_sections);
     //echo $user->name;
     // echo "<pre>";
     // print_r($data);
     // print_r(json_encode($data));
     //$data = json_encode($data);
     return json_encode($data);
 }
Example #3
0
 public function getAllEnrollments()
 {
     $enrollments = Enrollment::select('student_id', DB::raw('GROUP_CONCAT(section_id) AS section_ids'))->groupBy('student_id')->get()->toArray();
     $user_array = array();
     // echo "<pre>";
     // dd($enrollments);
     foreach ($enrollments as $enrollment) {
         $user = User::find($enrollment['student_id']);
         $section_array = explode(",", $enrollment['section_ids']);
         foreach ($section_array as $sid) {
             $sections[] = Vsection::find($sid);
         }
         $user_array[] = array('user' => $user, 'sections' => $sections);
         $sections = array();
     }
     // return view('reports.allSections');
     // return view('reports.enrollments-regular')->with('users',$user_array);
     //dd($user_array);
     return $user_array;
     // foreach($user_array[1]['sections'] as $s)
     //        echo $s->crn."<br>";
     // dd($user_array);
     // return $enrollments;
 }
Example #4
0
 public function dropAll()
 {
     $enrollments = Enrollment::where('student_id', '=', $this->id)->get();
     foreach ($enrollments as $enrollment) {
         Enrollment::drop($this->id, $enrollment->section_id);
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $enrollment = Enrollment::find($id);
     if (!$enrollment) {
         return $this->respondNotFound('Enrollment does not exist.');
     }
     if ($enrollment->delete()) {
         return $this->respond(['message' => 'The enrollment has been deleted.']);
     } else {
         return $this->respondUnprocessableEntity('There was a problem deleting the enrollment.');
     }
 }
Example #6
0
 public function run()
 {
     DB::table('enrollments')->delete();
     Enrollment::enroll(1, 1);
     Enrollment::enroll(1, 4);
 }