public function getCourse($coursecode) { $course = Course::where('c_code', 'LIKE', "%{$coursecode}%")->first(); if (!$course) { abort(404); } $notes = Note::where('course_id', $course->id)->orderBy('created_at', 'desc')->paginate(4); return view('course.index')->with('course', $course)->with('notes', $notes); }
public function getResults(Request $request) { $query = $request->input('query'); if (!$query) { return redirect()->route('home'); } $users = User::where(DB::raw("CONCAT(first_name, ' ', last_name)"), 'LIKE', "%{$query}%")->get(); $courses = Course::where('c_code', 'LIKE', "%{$query}%")->orWhere('c_name', 'LIKE', "%{$query}%")->get(); return view('search.results')->with('users', $users)->with('courses', $courses); }
public function index() { if (Auth::check()) { $courses = Course::all(); $notes = Note::where(function ($query) { return $query->where('user_id', Auth::user()->id)->orWhereIn('user_id', Auth::user()->whoIFollow()->lists('follow_id')); })->orderBy('created_at', 'desc')->paginate(4); return view('timeline.index')->with('mainuser', Auth::user())->with('courses', $courses)->with('notes', $notes); } return view('home'); }
public function removeCourse($coursecode) { $course = Course::where('c_code', 'LIKE', "%{$coursecode}%")->first(); if (!$course) { return redirect()->route('home')->with('info', 'That course could not be found.'); } if (!Auth::user()->isFollowingCourse($course)) { return redirect()->route('course.index', ['coursecode' => $course->getCourseCode()])->with('info', 'You are already not following this course.'); } Auth::user()->unFollowCourse($course); return redirect()->route('course.index', ['coursecode' => $course->getCourseCode()]); }
public function coursecodeofNote() { return Course::where('id', $this->course_id)->first()->getCourseCode(); }