public function getStudents($courseId) { return CourseStudent::where("course_id", $courseId)->get(); }
/** * Show the application dashboard to the user. * * @return Response */ public function index() { if ($this->adminAuth()) { $categories = Category::take(10)->get(); $users = User::where('type', 'teacher')->take(5)->get(); $courses = Course::take(10)->get(); return view('adminHome', compact('courses', 'users', 'categories')); } elseif ($this->teacherAuth()) { $courses = Course::where('user_id', Auth::User()->id)->take(10)->get(); return view('teacherHome', compact('courses')); } elseif ($this->studentAuth()) { $courseStudents = CourseStudent::where('user_id', Auth::User()->id)->take(10)->get(); return view('studentHome', compact('courseStudents')); } //return view('home'); }
public function inviteAll() { $courseId = Request::get('courseId'); $course = Course::find($courseId); $students = User::where('type', 'student')->get(); foreach ($students as $student) { # code... $data = json_decode(json_encode($student), true); $data['course_teacher_name'] = $course->user->name; $data['course_teacher_email'] = $course->user->email; $data['course_title'] = $course->title; $data['course_desc'] = $course->desc; $data['course_start_time'] = $course->start_time; $data['course_duration'] = $course->duration; $join = new CourseStudent(); $join->user_id = $student->id; $join->course_id = $courseId; $join->save(); Mail::send('emails.invitation', $data, function ($message) use($data) { $message->from('*****@*****.**', "invitation"); $message->subject("invitation for attende "); $message->to($data['email']); }); } echo var_dump($data); // echo $courseId; }
public function clearGp($gpId) { $students = CourseStudent::where("gp_id", $gpId); return $students->delete(); }