Esempio n. 1
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $title = 'Show Student';
     // in case it's not found
     Session::flash('http_status', 'Student not found.');
     // get a student
     $student = \ATC\Student::findOrFail($id);
     // student found
     Session::remove('http_status');
     $courses = \ATC\Course::with('term')->where('student_id', $id)->orderBy('name', 'ASC')->get();
     return view('student.show')->withTitle($title)->withStudent($student)->withCourses($courses);
 }
Esempio n. 2
0
 /**
  * Get sepecified resource or fail with HTTP 404
  *
  * @param  int  $id
  * @return \Illuminate\Database\Eloquent\Model
  */
 public static function getCourseWithOrFail($id)
 {
     // in case it's not found
     Session::flash('http_status', 'Course not found.');
     // get course with its term and its files sorted newest to oldest
     $course = \ATC\Course::with(['term', 'files' => function ($query) {
         $query->orderBy('updated_at', 'ASC');
     }])->findOrFail($id);
     // course found
     Session::remove('http_status');
     return $course;
 }
Esempio n. 3
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function addCourse($id)
 {
     $courses = \ATC\Course::with('student')->orderBy('name', 'asc')->get();
     // get a file
     $file = \ATC\File::getFileOrFail($id);
     $title = 'Add Course to ' . $file->name;
     return view('file.add')->withTitle($title)->withFile($file)->withCourses($courses);
 }