public function store($department_name, $department_number)
 {
     //Checks if user is Authorised
     if (\Auth::check()) {
         $newdescription = Request::get('description');
         //gets description from courses view
         $newcoursenumber = Request::get('sectionnumber');
         //gets section number from courses view
         //creates the new tuple
         course::insert(['department_name' => $department_name, 'dept_num' => $department_number, 'Description' => $newdescription, 'sectionnumber' => $newcoursenumber]);
         $message = "Add Course: Success";
         //tells user that it was a success
     } else {
         $message = "Add Course: Failed";
     }
     //tells user if it was a failure
     // filters results based on variables passed in to function to display desired courses. It will contain new tuple if successful
     $coursetable = course::where('dept_num', '=', $department_number)->where('department_name', '=', $department_name)->orderBy('sectionnumber', 'asc')->get();
     //tells user if logged in or not
     if (\Auth::check()) {
         $name = \Auth::user()->name;
     } else {
         $name = "Guest";
     }
     //returns the view courses. It passes coursetable, department_name, department_number, message, and name to the view
     return view('courses', compact('coursetable'), compact('department_name', 'department_number', 'message', 'name'));
 }
 public function run()
 {
     $faker = faker::create();
     $students = student::all()->lists('id');
     $course = ['physics', 'math', 'english', 'data structure', 'A.I'];
     foreach (range(1, 30) as $index) {
         course::create(array('student_id' => $faker->randomElement($students), 'course_name' => $faker->randomElement($course), 'created_at' => $faker->dateTimeBetween('now', '+14 days')));
     }
 }
Example #3
0
 public function courseStore(Request $request)
 {
     $input = new course();
     $input->user_id = $request->user_id;
     $input->title = $request->title;
     $input->code = $request->code;
     $input->associated = $request->associated;
     $input->save();
     return redirect('courses');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $data = course::findOrFail($id);
     $data->delete();
     return redirect('course');
 }