/** * Get sepecified resource or fail with HTTP 404 * * @param int $id * @return \Illuminate\Database\Eloquent\Model */ public static function getStudentOrFail($id) { // in case student is not found Session::flash('http_status', 'Student not found.'); // get the student $student = \ATC\Student::findOrFail($id); // student found Session::remove('http_status'); return $student; }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // in case it's not found Session::flash('http_status', 'Student not found.'); // get a student $student = \ATC\Student::findOrFail($id); // delete student, will cascade to delete their courses $student->delete(); Session::flash('flash_message', $student->initials . ' deleted'); // go to list view on staff member's home page return redirect('/'); }