/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { $id = Auth::user()->id; //dd($id); $trainingId = UserTraining::where('user_id', '=', $id)->FirstOrFail()->trainings_id; // dd($trainingId); $trainers = DB::table('users')->join('trainercourses', 'trainercourses.trainer_id', '=', 'users.id')->join('courses', 'courses.id', '=', 'trainercourses.course_id')->where('courses.training_id', $trainingId)->get(); //dd($trainers); return view('feedbacks.create', compact('trainers')); }
/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create($trackId, $trainingId) { $course_name = Course::where('id', '=', $trackId)->pluck('course_name'); $user_id_training = UserTraining::where('trainings_id', '=', $trainingId)->get(); //dd($user_id_training); //$trainees = User::lists('id', 'name'); $trainees = User::all(); $courses = Course::lists('course_name', 'id'); $newTrainees = array(); $test = ""; foreach ($user_id_training as $traineesName) { //dd($traineesName); //$newTrainees++; $traineeHas = TraineeCourse::wheretrainee_id($traineesName->user_id)->wherecourse_id($trackId)->first(); if ($traineeHas == true) { $test++; } else { array_push($newTrainees, $traineesName->user_id); } } //dd($newTrainees); return view('traineeCourse.create', compact('trainees', 'trackId', 'course_name', 'newTrainees')); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $traineingSubject = UserTraining::whereid($id); $traineingSubject->delete(); return redirect('/user_traininginfo')->with('status', 'Delete successfully'); }
public function number_of_trainee_by_training_id($training_id) { return UserTraining::where('trainings_id', $training_id)->get()->count(); }